format-table: allow to explicitly override JSON field names
authorLennart Poettering <lennart@poettering.net>
Fri, 3 Sep 2021 09:11:18 +0000 (11:11 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 3 Sep 2021 13:37:26 +0000 (14:37 +0100)
commitb03803f0dc46613edaa34355786d6d3c1dec228c
treea850e9b94f01bc30bd33d5a95395ebde1548d7d5
parent0d5765f7af96702031a6ce12d2f65238337a2e40
format-table: allow to explicitly override JSON field names

In some cases it's useful to explicitly generate the JSON field names to
generate for table columns, instead of auto-mangling them from table
header names that are intended for human consumption.

This adds the infra and a test for it.

It's intended to be used by #20544, for the first column, which in text
mode should have an empty header field, but have an explicit name in
json output mode.
src/shared/format-table.c
src/shared/format-table.h
src/test/test-format-table.c