summaryrefslogtreecommitdiffstats
path: root/text-utils
diff options
context:
space:
mode:
authorKarel Zak2017-03-29 12:38:52 +0200
committerKarel Zak2017-05-02 12:18:00 +0200
commit1ae24ec2390055b41191e32a20787bda3d0e9c1e (patch)
tree80378b953fb3d3e6373c1f2e535e268a7c2bfaec /text-utils
parentcolumn: add --table-truncate (diff)
downloadkernel-qcow2-util-linux-1ae24ec2390055b41191e32a20787bda3d0e9c1e.tar.gz
kernel-qcow2-util-linux-1ae24ec2390055b41191e32a20787bda3d0e9c1e.tar.xz
kernel-qcow2-util-linux-1ae24ec2390055b41191e32a20787bda3d0e9c1e.zip
column: add --table-noextreme
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils')
-rw-r--r--text-utils/column.16
-rw-r--r--text-utils/column.c20
2 files changed, 20 insertions, 6 deletions
diff --git a/text-utils/column.1 b/text-utils/column.1
index ca33c1ef5..8117b6bf9 100644
--- a/text-utils/column.1
+++ b/text-utils/column.1
@@ -71,6 +71,12 @@ Specify columns where is allowed to truncate text when necessary, otherwise
very long table entries may be printed on multiple lines. The \fIcolumns\fP is
comma separated list of the column names (see \fB\-\-table-columns\fP) or
column number.
+.IP "\fB\-E, \-\-table-noextreme\fP \fIcolumns\fP"
+Specify columns where is possible to ignore unusually long (longer than
+average) cells when calculate column width. The option has impact to the width
+calculation, but the printed text is not affected. The \fIcolumns\fP is
+comma separated list of the column names (see \fB\-\-table-columns\fP) or
+column number.
.IP "\fB\-n, \-\-table-name\fP \fIname\fP"
Specify the table name used for JSON output. The defaout is "table".
.IP "\fB\-x, \-\-fillrows\fP"
diff --git a/text-utils/column.c b/text-utils/column.c
index f9f191ec0..66f7e6c54 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -72,8 +72,9 @@ struct column_control {
char **tab_colnames; /* array with column names */
const char *tab_name; /* table name */
- const char *tab_colright; /* non-parsed --table-right */
- const char *tab_coltrunc; /* non-parsed --table-trunc */
+ const char *tab_colright; /* --table-right */
+ const char *tab_coltrunc; /* --table-trunc */
+ const char *tab_colnoextrem; /* --table-noextreme */
wchar_t *input_separator;
const char *output_separator;
@@ -247,15 +248,17 @@ static void modify_table(struct column_control *ctl)
{
scols_table_set_termwidth(ctl->tab, ctl->termwidth);
- /* align text in columns to right */
if (ctl->tab_colright)
apply_columnflag_from_list(ctl, ctl->tab_colright,
SCOLS_FL_RIGHT, _("failed to parse --table-right list"));
- /* truncate text in columns */
if (ctl->tab_coltrunc)
apply_columnflag_from_list(ctl, ctl->tab_coltrunc,
SCOLS_FL_TRUNC , _("failed to parse --table-trunc list"));
+
+ if (ctl->tab_colnoextrem)
+ apply_columnflag_from_list(ctl, ctl->tab_colnoextrem,
+ SCOLS_FL_NOEXTREMES , _("failed to parse --table-noextreme list"));
}
static int add_line_to_table(struct column_control *ctl, wchar_t *wcs)
@@ -429,7 +432,8 @@ static void __attribute__((__noreturn__)) usage(int rc)
fputs(_(" -t, --table create a table\n"), out);
fputs(_(" -N, --table-columns <names> comma separated columns names\n"), out);
fputs(_(" -R, --table-right <columns> right align text in these columns\n"), out);
- fputs(_(" -T, --table-truncate <columns> truncate text in these columns when necessary\n"), out);
+ fputs(_(" -T, --table-truncate <columns> truncate text in the columns when necessary\n"), out);
+ fputs(_(" -E, --table-noextreme <column> don't count long text from the columns to column width\n"), out);
fputs(_(" -n, --table-name <name> table name for JSON output\n"), out);
fputs(_(" -s, --separator <string> possible table delimiters\n"), out);
fputs(_(" -o, --output-separator <string> columns separator for table output\n"
@@ -467,6 +471,7 @@ int main(int argc, char **argv)
{ "table-columns", required_argument, NULL, 'N' },
{ "table-right", required_argument, NULL, 'R' },
{ "table-truncate", required_argument, NULL, 'T' },
+ { "table-noextreme", required_argument, NULL, 'E' },
{ "table-name", required_argument, NULL, 'n' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 },
@@ -487,11 +492,14 @@ int main(int argc, char **argv)
ctl.output_separator = " ";
ctl.input_separator = mbs_to_wcs("\t ");
- while ((c = getopt_long(argc, argv, "hVc:Jn:N:R:s:txo:T:", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hVc:Jn:N:R:s:txo:T:E:", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
switch(c) {
+ case 'E':
+ ctl.tab_colnoextrem = optarg;
+ break;
case 'J':
ctl.json = 1;
ctl.mode = COLUMN_MODE_TABLE;