Specify columns order on output.
.IP "\fB\-n, \-\-table-name\fP \fIname\fP"
Specify the table name used for JSON output. The default is "table".
+.IP "\fB\-L, \-\-table\-empty\-lines\fP"
+Insert empty line to the table for each empty line on input. The default
+is ignore empty lines at all.
.IP "\fB\-r, \-\-tree\fP \fIcolumn\fP"
Specify column to use tree-like output. Note that the circular dependencies and
another anomalies in child and parent relation are silently ignored.
unsigned int greedy :1,
json :1,
header_repeat :1,
+ tab_empty_lines :1, /* --table-empty-lines */
tab_noheadings :1;
};
return 0;
}
+static int add_emptyline_to_table(struct column_control *ctl)
+{
+ if (!ctl->tab)
+ init_table(ctl);
+
+ if (!scols_table_new_line(ctl->tab, NULL))
+ err(EXIT_FAILURE, _("failed to allocate output line"));
+
+ return 0;
+}
+
static int read_input(struct column_control *ctl, FILE *fp)
{
char *buf = NULL;
if (p)
*p = '\0';
}
- if (!str || !*str)
+ if (!str || !*str) {
+ if (ctl->mode == COLUMN_MODE_TABLE && ctl->tab_empty_lines)
+ add_emptyline_to_table(ctl);
continue;
+ }
wcs = mbs_to_wcs(buf);
if (!wcs) {
fputs(_(" -R, --table-right <columns> right align text in these columns\n"), out);
fputs(_(" -T, --table-truncate <columns> truncate text in the columns when necessary\n"), out);
fputs(_(" -W, --table-wrap <columns> wrap text in the columns when necessary\n"), out);
+ fputs(_(" -L, --table-empty-lines don't ignore empty lines\n"), out);
fputs(_(" -J, --json use JSON output format for table\n"), out);
fputs(USAGE_SEPARATOR, out);
{ "table-right", required_argument, NULL, 'R' },
{ "table-truncate", required_argument, NULL, 'T' },
{ "table-wrap", required_argument, NULL, 'W' },
+ { "table-empty-lines", no_argument, NULL, 'L' },
{ "table-header-repeat", no_argument, NULL, 'e' },
{ "tree", required_argument, NULL, 'r' },
{ "tree-id", required_argument, NULL, 'i' },
ctl.output_separator = " ";
ctl.input_separator = mbs_to_wcs("\t ");
- while ((c = getopt_long(argc, argv, "c:dE: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:JLN:n:O:o:p:R:r:s:T:tVW:x", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
ctl.json = 1;
ctl.mode = COLUMN_MODE_TABLE;
break;
+ case 'L':
+ ctl.tab_empty_lines = 1;
+ break;
case 'N':
ctl.tab_colnames = split_or_error(optarg, _("failed to parse column names"));
break;