From 94dbb322737524027a55e6ed5646dc69c5ed9e5b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 23 Jul 2019 16:04:51 +0200 Subject: libsmartcols: cleanup and extend padding functionality LIBSMARTCOLS_DEBUG_PADDING=on in the next examples forces libsmartcols print '.' as a padding char. See line "ffff" in the exmaples. * default output is to fill all except last cell $ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10 --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null NAME.. ......NUM STRINGS STRINGS aaaa.. ........0 aaaa... aaaa bbb... ......100 bbb.... bbb ccccc. .......21 ccccc.. ccccc dddddd ........3 dddddd. dddddd ee.... ......411 ee..... ee ffff.. .....5111 ....... gggggg 678993321 gggggg. gggggg hhh... ..7666666 hhh.... hhh * scols_table_enable_minout() minimizes output for tailing empty cells, example: $ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10 --minout --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null NAME.. ......NUM STRINGS STRINGS aaaa.. ........0 aaaa... aaaa bbb... ......100 bbb.... bbb ccccc. .......21 ccccc.. ccccc dddddd ........3 dddddd. dddddd ee.... ......411 ee..... ee ffff.. .....5111 gggggg 678993321 gggggg. gggggg hhh... ..7666666 hhh.... hhh * cleanup up scols_table_enable_maxout() use, example: $ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10 --maxout --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null NAME.............. ..................NUM STRINGS............ STRINGS............ aaaa.............. ....................0 aaaa............... aaaa............... bbb............... ..................100 bbb................ bbb................ ccccc............. ...................21 ccccc.............. ccccc.............. dddddd............ ....................3 dddddd............. dddddd............. ee................ ..................411 ee................. ee................. ffff.............. .................5111 ................... ................... gggggg............ ............678993321 gggggg............. gggggg............. hhh............... ..............7666666 hhh................ hhh................ Note that we cannot make scols_table_enable_minout() default because for example "column --table" is pretty commonly used with non-blank columns separator and in this case all cells has to be filled. $ echo -e "aa,b,ccc\na,,\naaa,bbb,ccc" | column --table --separator ',' --output-separator '|' aa |b |ccc a | | aaa|bbb|ccc Addresses: https://github.com/karelzak/util-linux/issues/826 Signed-off-by: Karel Zak --- tests/expected/lsblk/lsblk-simple-lvm-vendor | 38 +++++++++++++-------------- tests/expected/lsblk/lsblk-simple-nvme-vendor | 22 ++++++++-------- 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'tests') diff --git a/tests/expected/lsblk/lsblk-simple-lvm-vendor b/tests/expected/lsblk/lsblk-simple-lvm-vendor index 591c703af..24ee97dd4 100644 --- a/tests/expected/lsblk/lsblk-simple-lvm-vendor +++ b/tests/expected/lsblk/lsblk-simple-lvm-vendor @@ -1,22 +1,22 @@ NAME MODEL VENDOR REV -loop0 -`-vg_foo.4059-lv_foo.4059 -loop1 -`-vg_foo.4059-lv_foo.4059 -loop2 -`-vg_foo.4059-lv_foo.4059 -loop3 -`-vg_foo.4059-lv_foo.4059 +loop0 +`-vg_foo.4059-lv_foo.4059 +loop1 +`-vg_foo.4059-lv_foo.4059 +loop2 +`-vg_foo.4059-lv_foo.4059 +loop3 +`-vg_foo.4059-lv_foo.4059 sda KINGSTON SH103S3 ATA BBF0 -|-sda1 -|-sda2 -|-sda3 -|-sda4 -|-sda5 -`-sda6 +|-sda1 +|-sda2 +|-sda3 +|-sda4 +|-sda5 +`-sda6 sdb WDC WD800JD-00MS ATA 1E01 -`-sdb1 -nvme0n1 KINGSTON SKC1000240G -|-nvme0n1p1 -|-nvme0n1p2 -`-nvme0n1p3 +`-sdb1 +nvme0n1 KINGSTON SKC1000240G +|-nvme0n1p1 +|-nvme0n1p2 +`-nvme0n1p3 diff --git a/tests/expected/lsblk/lsblk-simple-nvme-vendor b/tests/expected/lsblk/lsblk-simple-nvme-vendor index 69e972a31..2a0a90514 100644 --- a/tests/expected/lsblk/lsblk-simple-nvme-vendor +++ b/tests/expected/lsblk/lsblk-simple-nvme-vendor @@ -1,14 +1,14 @@ NAME MODEL VENDOR REV sda KINGSTON SH103S3 ATA BBF0 -|-sda1 -|-sda2 -|-sda3 -|-sda4 -|-sda5 -`-sda6 +|-sda1 +|-sda2 +|-sda3 +|-sda4 +|-sda5 +`-sda6 sdb WDC WD800JD-00MS ATA 1E01 -`-sdb1 -nvme0n1 KINGSTON SKC1000240G -|-nvme0n1p1 -|-nvme0n1p2 -`-nvme0n1p3 +`-sdb1 +nvme0n1 KINGSTON SKC1000240G +|-nvme0n1p1 +|-nvme0n1p2 +`-nvme0n1p3 -- cgit v1.2.3-55-g7522