]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
column: add --table-maxout
authorKarel Zak <kzak@redhat.com>
Mon, 6 Jun 2022 09:41:35 +0000 (11:41 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 6 Jun 2022 09:45:07 +0000 (11:45 +0200)
Add option to fill all available space.

Fizes: https://github.com/util-linux/util-linux/issues/1700
Signed-off-by: Karel Zak <kzak@redhat.com>
bash-completion/column
text-utils/column.1.adoc
text-utils/column.c

index 5ce56e76fce36d35ea9f604e76e4318b53e048fb..3de9f16dac38e61f9d860cb84b4562cb387d616d 100644 (file)
@@ -35,6 +35,7 @@ _column_module()
                                --table-columns-limit
                                --table-noextreme
                                --table-noheadings
+                               --table-maxout
                                --table-header-repeat
                                --table-hide
                                --table-right
index dfb5adfc0610d98fc02fdb7bcacc468504b94101..6da1dccfee774334c75b5ef0629b2dba74568788 100644 (file)
@@ -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.
 
index a78e2a6af827422de3b720da696ca05020475bdd..f3a260cabea62b4b8596a102419607ffadbaee7e 100644 (file)
@@ -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 <num>  maximal number of input columns\n"), out);
        fputs(_(" -E, --table-noextreme <columns>  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 <columns>       don't print the columns\n"), out);
        fputs(_(" -R, --table-right <columns>      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;