column names as defined by *--table-columns*, or names defined by
*--table-column* or it's column number in order as specified by input. It's
possible to mix names and numbers. The special placeholder '0' (e.g. -R0) may
-be used to specify all columns.
+be used to specify all columns and '-1' (e.g. -R -1) to specify the last visible column.
*-J, --json*::
Use JSON output format to print the table, the option *--table-columns* is required and the option *--table-name* is recommended.
}
-static struct libscols_column *string_to_column(struct column_control *ctl, const char *str)
-{
- struct libscols_column *cl;
-
- if (isdigit_string(str)) {
- uint32_t n = strtou32_or_err(str, _("failed to parse column")) - 1;
-
- cl = scols_table_get_column(ctl->tab, n);
- } else
- cl = scols_table_get_column_by_name(ctl->tab, str);
-
- if (!cl)
- errx(EXIT_FAILURE, _("undefined column name '%s'"), str);
-
- return cl;
-}
-
static struct libscols_column *get_last_visible_column(struct column_control *ctl)
{
struct libscols_iter *itr;
return last;
}
+static struct libscols_column *string_to_column(struct column_control *ctl, const char *str)
+{
+ struct libscols_column *cl;
+
+ if (isdigit_string(str)) {
+ uint32_t n = strtou32_or_err(str, _("failed to parse column")) - 1;
+
+ cl = scols_table_get_column(ctl->tab, n);
+ } else if (strcmp(str, "-1") == 0)
+ cl = get_last_visible_column(ctl);
+ else
+ cl = scols_table_get_column_by_name(ctl->tab, str);
+
+ if (!cl)
+ errx(EXIT_FAILURE, _("undefined column name '%s'"), str);
+
+ return cl;
+}
+
static int column_set_flag(struct libscols_column *cl, int fl)
{
int cur = scols_column_get_flags(cl);