From: Karel Zak Date: Tue, 13 Jun 2017 09:14:46 +0000 (+0200) Subject: column: add --table-header-repeat X-Git-Tag: v2.31-rc1~321 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9eddf72a35e8e122de1135e5731198842fa2cac;p=thirdparty%2Futil-linux.git column: add --table-header-repeat Signed-off-by: Karel Zak --- diff --git a/text-utils/column.1 b/text-utils/column.1 index 03f669789c..6baa0464a3 100644 --- a/text-utils/column.1 +++ b/text-utils/column.1 @@ -91,6 +91,9 @@ average) cells when calculate column width. The option has impact to the width calculation and table formatting, but the printed text is not affected. The option is used for the last visible column by default. + +.IP "\fB\-e, \-\-table\-header\-repeat\fP" +Print header line for each page. .IP "\fB\-W, \-\-table-wrap\fP \fIcolumns\fP" Specify columns where is possible to use multi-line cell for long text when necessary. diff --git a/text-utils/column.c b/text-utils/column.c index c315f91ef6..c036b4de89 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -92,7 +92,8 @@ struct column_control { size_t maxlength; /* longest input record (line) */ unsigned int greedy :1, - json :1; + json :1, + header_repeat :1; }; static size_t width(const wchar_t *str) @@ -205,6 +206,8 @@ static void init_table(struct column_control *ctl) STRV_FOREACH(name, ctl->tab_colnames) scols_table_new_column(ctl->tab, *name, 0, 0); + if (ctl->header_repeat) + scols_table_enable_header_repeat(ctl->tab, 1); } else scols_table_enable_noheadings(ctl->tab, 1); } @@ -559,6 +562,7 @@ static void __attribute__((__noreturn__)) usage(int rc) fputs(_(" -O, --table-order specify order of output columns\n"), out); fputs(_(" -N, --table-columns comma separated columns names\n"), out); fputs(_(" -E, --table-noextreme don't count long text from the columns to column width\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); fputs(_(" -T, --table-truncate truncate text in the columns when necessary\n"), out); @@ -613,6 +617,7 @@ int main(int argc, char **argv) { "table-right", required_argument, NULL, 'R' }, { "table-truncate", required_argument, NULL, 'T' }, { "table-wrap", required_argument, NULL, 'W' }, + { "table-header-repeat", no_argument, NULL, 'e' }, { "tree", required_argument, NULL, 'r' }, { "tree-id", required_argument, NULL, 'i' }, { "tree-parent", required_argument, NULL, 'p' }, @@ -634,7 +639,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:H:hi:JN:n:O:o:p:R:r:s:T:tVW:x", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "c:E:eH:hi:JN:n:O:o:p:R:r:s:T:tVW:x", longopts, NULL)) != -1) { err_exclusive_options(c, longopts, excl, excl_st); @@ -645,6 +650,9 @@ int main(int argc, char **argv) case 'E': ctl.tab_colnoextrem = optarg; break; + case 'e': + ctl.header_repeat = 1; + break; case 'H': ctl.tab_colhide = optarg; break;