]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
column: add --table-noheadings
authorKarel Zak <kzak@redhat.com>
Mon, 13 Nov 2017 11:56:21 +0000 (12:56 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Nov 2017 11:56:21 +0000 (12:56 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/column.1
text-utils/column.c

index 6baa0464a3f0da1b6d7522efe403873730fb031a..3bcd0f086e59cc16cf954e3e0245d9674f09dc2a 100644 (file)
@@ -68,6 +68,8 @@ Use JSON output format to print the table, the option
 Output is formatted to a width specified as number of characters. The original
 name of this option is --columns; this name is deprecated since v2.30. Note that input
 longer than \fIwidth\fP is not truncated by default.
+.IP "\fB\-d, \-\-table\-noheadings\fP"
+Do not print header. This option allows to use logical column names on command line, but keep the header hidden when print the table.
 .IP "\fB\-o, \-\-output\-separator\fP \fIstring\fP"
 Specify the columns delimiter for table output (default is two spaces).
 .IP "\fB\-s, \-\-separator\fP \fIseparators\fP"
index d34cfc3f0d6aeed4b55a70cb4701501c82e181c9..0a17c69cb98a4fd16d392055503b0efa501e3c5e 100644 (file)
@@ -93,7 +93,8 @@ struct column_control {
 
        unsigned int greedy :1,
                     json :1,
-                    header_repeat :1;
+                    header_repeat :1,
+                    tab_noheadings :1;
 };
 
 static size_t width(const wchar_t *str)
@@ -218,6 +219,7 @@ static void init_table(struct column_control *ctl)
                        scols_table_new_column(ctl->tab, *name, 0, 0);
                if (ctl->header_repeat)
                        scols_table_enable_header_repeat(ctl->tab, 1);
+               scols_table_enable_noheadings(ctl->tab, !!ctl->tab_noheadings);
        } else
                scols_table_enable_noheadings(ctl->tab, 1);
 }
@@ -572,6 +574,7 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_(" -O, --table-order <columns>      specify order of output columns\n"), out);
        fputs(_(" -N, --table-columns <names>      comma separated columns names\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(_(" -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);
@@ -622,6 +625,7 @@ int main(int argc, char **argv)
                { "table-hide",          required_argument, NULL, 'H' },
                { "table-name",          required_argument, NULL, 'n' },
                { "table-noextreme",     required_argument, NULL, 'E' },
+               { "table-noheadings",    no_argument,       NULL, 'd' },
                { "table-order",         required_argument, NULL, 'O' },
                { "table-right",         required_argument, NULL, 'R' },
                { "table-truncate",      required_argument, NULL, 'T' },
@@ -648,7 +652,7 @@ int main(int argc, char **argv)
        ctl.output_separator = "  ";
        ctl.input_separator = mbs_to_wcs("\t ");
 
-       while ((c = getopt_long(argc, argv, "c:E:eH:hi:JN:n:O:o:p:R:r:s:T:tVW:x", longopts, NULL)) != -1) {
+       while ((c = getopt_long(argc, argv, "c:dE:eH:hi:JN:n:O:o:p:R:r:s:T:tVW:x", longopts, NULL)) != -1) {
 
                err_exclusive_options(c, longopts, excl, excl_st);
 
@@ -656,6 +660,9 @@ int main(int argc, char **argv)
                case 'c':
                        ctl.termwidth = strtou32_or_err(optarg, _("invalid columns argument"));
                        break;
+               case 'd':
+                       ctl.tab_noheadings = 1;
+                       break;
                case 'E':
                        ctl.tab_colnoextrem = optarg;
                        break;