From: Karel Zak Date: Mon, 6 Jun 2022 09:41:35 +0000 (+0200) Subject: column: add --table-maxout X-Git-Tag: v2.39-rc1~640 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6be39224f31ac81ba65c384fda90f9f52d41136f;p=thirdparty%2Futil-linux.git column: add --table-maxout Add option to fill all available space. Fizes: https://github.com/util-linux/util-linux/issues/1700 Signed-off-by: Karel Zak --- diff --git a/bash-completion/column b/bash-completion/column index 5ce56e76fc..3de9f16dac 100644 --- a/bash-completion/column +++ b/bash-completion/column @@ -35,6 +35,7 @@ _column_module() --table-columns-limit --table-noextreme --table-noheadings + --table-maxout --table-header-repeat --table-hide --table-right diff --git a/text-utils/column.1.adoc b/text-utils/column.1.adoc index dfb5adfc06..6da1dccfee 100644 --- a/text-utils/column.1.adoc +++ b/text-utils/column.1.adoc @@ -153,6 +153,9 @@ Specify columns order on output. *-n, --table-name* _name_:: Specify the table name used for JSON output. The default is "table". +*-m, --table-maxout*:: +Fill all available space on output. + *-L, --keep-empty-lines*:: Preserve whitespace-only lines in the input. The default is ignore empty lines at all. This option's original name was *--table-empty-lines* but is now deprecated because it gives the false impression that the option only applies to table mode. diff --git a/text-utils/column.c b/text-utils/column.c index a78e2a6af8..f3a260cabe 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -99,6 +99,7 @@ struct column_control { json :1, header_repeat :1, hide_unnamed :1, + maxout : 1, keep_empty_lines :1, /* --keep-empty-lines */ tab_noheadings :1; }; @@ -222,6 +223,8 @@ static void init_table(struct column_control *ctl) } else scols_table_enable_noencoding(ctl->tab, 1); + scols_table_enable_maxout(ctl->tab, ctl->maxout ? 1 : 0); + if (ctl->tab_columns) { char **opts; @@ -717,6 +720,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -l, --table-columns-limit maximal number of input columns\n"), out); fputs(_(" -E, --table-noextreme don't count long text from the columns to column width\n"), out); fputs(_(" -d, --table-noheadings don't print header\n"), out); + fputs(_(" -m, --table-maxout fill all available space\n"), out); fputs(_(" -e, --table-header-repeat repeat header for each page\n"), out); fputs(_(" -H, --table-hide don't print the columns\n"), out); fputs(_(" -R, --table-right right align text in these columns\n"), out); @@ -771,6 +775,7 @@ int main(int argc, char **argv) { "table-columns-limit", required_argument, NULL, 'l' }, { "table-hide", required_argument, NULL, 'H' }, { "table-name", required_argument, NULL, 'n' }, + { "table-maxout", no_argument, NULL, 'm' }, { "table-noextreme", required_argument, NULL, 'E' }, { "table-noheadings", no_argument, NULL, 'd' }, { "table-order", required_argument, NULL, 'O' }, @@ -801,7 +806,7 @@ int main(int argc, char **argv) ctl.output_separator = " "; ctl.input_separator = mbs_to_wcs("\t "); - while ((c = getopt_long(argc, argv, "C:c:dE:eH:hi:Jl:LN:n:O:o:p:R:r:s:T:tVW:x", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "C:c:dE:eH:hi:Jl:LN:n:mO:o:p:R:r:s:T:tVW:x", longopts, NULL)) != -1) { err_exclusive_options(c, longopts, excl, excl_st); @@ -850,6 +855,9 @@ int main(int argc, char **argv) case 'n': ctl.tab_name = optarg; break; + case 'm': + ctl.maxout = 1; + break; case 'O': ctl.tab_order = optarg; break;