Commit Graph

38 Commits

Author SHA1 Message Date
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Zbigniew Jędrzejewski-Szmek b0e3d79989 format-table: add TABLE_STRV_WRAPPED
The idea is that we have strvs like list of server names or addresses, where
the majority of strings is rather short, but some are long and there can
potentially be many strings. So formattting them either all on one line or all
in separate lines leads to output that is either hard to read or uses way too
many rows. We want to wrap them, but relying on the pager to do the wrapping is
not nice. Normal text has a lot of redundancy, so when the pager wraps a line
in the middle of a word the read can understand what is going on without any
trouble. But for a high-density zero-redundancy text like an IP address it is
much nicer to wrap between words. This also makes c&p easier.

This adds a variant of TABLE_STRV which is wrapped on output (with line breaks
inserted between different strv entries).

The change table_print() is quite ugly. A second pass is added to re-calculate
column widths. Since column size is now "soft", i.e. it can adjust based on
available columns, we need to two passes:
- first we figure out how much space we want
- in the second pass we figure out what the actual wrapped columns
  widths will be.

To avoid unnessary work, the second pass is only done when we actually have
wrappable fields.

A test is added in test-format-table.
2020-10-22 13:20:40 +02:00
fangxiuning 4b6607d949 table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
fangxiuning df83eb546b table add table_log_sort_error() 2020-07-08 10:53:57 +08:00
fangxiuning d836018a73 table add table_log_show_error() 2020-07-08 10:50:59 +08:00
Lennart Poettering b0395c1176 format-table: support coloring the gap right of each cell individually
This is useful for underlining a whole row of cells: previously we
couldn't underline the gap. Now we can.
2020-05-06 15:40:15 +02:00
Frantisek Sumsal 0080964cc8 format-table: allow hiding a specific column
without having to specify the whole display map
2020-03-11 14:43:52 +01:00
Lennart Poettering 137688dff4 format-table: add support for formatting uuids/id128 values 2020-01-20 17:42:03 +01:00
Yu Watanabe 4618660d10 format-table: introduce TABLE_STRV 2020-01-15 11:52:40 +09:00
Lennart Poettering d91614e717 format-table: natively support multiline cells
This adds native support for multiline cells.
2020-01-13 16:38:28 +01:00
Yu Watanabe d8aedafb57 format-table: add table_log_add_error() 2020-01-10 18:23:20 +09:00
Yu Watanabe f93d876c80 format-table: introduce TABLE_PATH 2020-01-09 20:16:03 +09:00
Lennart Poettering b26c0b68a4 format-table: add UID/GID output support to format-table.h 2019-11-19 12:10:44 +01:00
Lennart Poettering cd2d52d34f
Merge pull request #13216 from poettering/busctl-format-table
port "busctl list" to format-table.h
2019-07-29 20:44:54 +02:00
Lennart Poettering a8a3392d6b format-table: add TABLE_PID cell type 2019-07-29 18:48:41 +02:00
Lennart Poettering 728a22d3b1 format-table: add table_fill_empty() to fill in empty cells until the specified column is reached 2019-07-29 18:48:28 +02:00
Lennart Poettering 7a9b4bb050 format-table: optionally show a specific string in empty cells
For some cases it might make sense to show "-" instead of just spaces
for empty cells.
2019-07-29 18:48:08 +02:00
Yu Watanabe e74294c30a table: add TABLE_UINT8 or friends 2019-07-29 23:27:56 +09:00
Yu Watanabe a7a257cdda table: add TABLE_IN_ADDR and TABLE_IN6_ADDR 2019-07-29 23:22:14 +09:00
Lennart Poettering c1b71f3a61
Merge pull request #13074 from poettering/format-tree-many
table_add_many() improvements
2019-07-16 16:03:54 +02:00
Lennart Poettering 6268974f88 format-table: add ability to set cell attributes within table_add_many()
table_add_many() is so much shorter and easier to read than
table_add_cell() with its accessors. Let's teach table_add_many() more
tricks, so that reverting to table_add_cell() is not needed that often
anymore.
2019-07-16 12:43:46 +02:00
Lennart Poettering dc0e9c9ba6 format-table: fix parameter name 2019-07-16 12:42:19 +02:00
Yu Watanabe c5bbb2b5be format-table: add TABLE_TIMESTAMP_UTC and _RELATIVE 2019-07-16 00:44:14 +09:00
Yu Watanabe ba99f19c0d format-table: add TABLE_TIMESPAN_MSEC 2019-07-16 00:09:39 +09:00
Yu Watanabe 9ff27e6413 table: introduce FORMAT_BPS type 2019-06-19 23:15:19 +09:00
Yu Watanabe 8390d39165 table: add TABLE_IFINDEX type 2019-05-29 14:21:19 +09:00
Yu Watanabe d553832698 table: add more basic types 2019-05-29 14:21:19 +09:00
Yu Watanabe 5896e03c6f table: add teble_add_string_cell() 2019-05-29 14:21:19 +09:00
Lennart Poettering a1c7a1f057 format-table: correct prototype 2019-05-08 06:33:36 -04:00
Lennart Poettering 359abf6dd0 format-table: add option to uppercase cells on display
This adds a per-cell option for uppercasing displayed strings.
Implicitly turn this on for the header row. The fact that we format the
table header in uppercase is a formatting thing after all, hence should
be applied by the formatter, i.e. the table display code.

Moreover, this provides us with the benefit that we can more nicely
reuse the specified table headers as JSON field names, like we already
do: json field names are usually not uppercase.
2018-12-03 22:42:38 +01:00
Lennart Poettering 31ac235771 format-table: optionally covert/output table to JSON 2018-12-03 22:42:38 +01:00
Lennart Poettering 62d99b3970 format-table: add calls to query the data in a specific cell 2018-11-30 16:46:10 +01:00
Lennart Poettering 9314ead785 format-table: add an API for getting the cell at a specific row/column 2018-11-30 16:46:10 +01:00
Lennart Poettering 27e730e6d0 format-table: add table_update() to update existing entries 2018-11-30 16:46:10 +01:00
Lennart Poettering a2c73e2d38 format-table: optionally allow reversing the sort order for a column 2018-11-30 16:46:10 +01:00
Lennart Poettering a4661181fa format-table: add option to store/format percent and uint64_t values in cells 2018-11-30 16:46:10 +01:00
Lennart Poettering 165ca5663e format-table: optionally make specific cells clickable links 2018-11-30 16:46:10 +01:00
Zbigniew Jędrzejewski-Szmek d284b82b3e Move various files that don't need to be in basic/ to shared/
This doesn't have much effect on the final build, because we link libbasic.a
into libsystemd-shared.so, so in the end, all the object built from basic/
end up in libsystemd-shared. And when the static library is linked into binaries,
any objects that are included in it but are not used are trimmed. Hence, the
size of output artifacts doesn't change:

$ du -sb /var/tmp/inst*
54181861	/var/tmp/inst1    (old)
54207441	/var/tmp/inst1s   (old split-usr)
54182477	/var/tmp/inst2    (new)
54208041	/var/tmp/inst2s   (new split-usr)

(The negligible change in size is because libsystemd-shared.so is bigger
by a few hundred bytes. I guess it's because symbols are named differently
or something like that.)

The effect is on the build process, in particular partial builds. This change
effectively moves the requirements on some build steps toward the leaves of the
dependency tree. Two effects:
- when building items that do not depend on libsystemd-shared, we
  build less stuff for libbasic.a (which wouldn't be used anyway,
  so it's a net win).
- when building items that do depend on libshared, we reduce libbasic.a as a
  synchronization point, possibly allowing better parallelism.

Method:
1. copy list of .h files from src/basic/meson.build to /tmp/basic
2. $ for i in $(grep '.h$' /tmp/basic); do echo $i; git --no-pager grep "include \"$i\"" src/basic/ 'src/lib*' 'src/nss-*' 'src/journal/sd-journal.c' |grep -v "${i%.h}.c";echo ;done | less
2018-11-20 07:27:37 +01:00
Renamed from src/basic/format-table.h (Browse further)