column: add --table-noheadings

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2017-11-13 12:56:21 +01:00
parent cfcbf7526a
commit 785e543645
2 changed files with 11 additions and 2 deletions

View 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"

View 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;