From bcb58ce069b91970c68e4c38385fa3b43dbc07dc Mon Sep 17 00:00:00 2001 From: Lance Richardson Date: Fri, 31 Mar 2017 13:21:03 -0400 Subject: [PATCH] table: provide table formatting option help at runtime Show table formatting options with help output from ovn-nbctl, obn-sbctl, ovs-vsctl, and vtep-ctl commands. Include "--data" option in ovsdb-client help output. Signed-off-by: Lance Richardson Signed-off-by: Ben Pfaff --- lib/table.c | 16 ++++++++++++++++ lib/table.h | 1 + ovn/utilities/ovn-nbctl.c | 1 + ovn/utilities/ovn-sbctl.c | 1 + ovsdb/ovsdb-client.c | 9 ++------- utilities/ovs-vsctl.c | 1 + vtep/vtep-ctl.c | 1 + 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/table.c b/lib/table.c index 9158499bf..6136beb2f 100644 --- a/lib/table.c +++ b/lib/table.c @@ -594,3 +594,19 @@ table_print(const struct table *table, const struct table_style *style) break; } } + +void +table_usage(void) +{ + printf("\nOutput formatting options:\n" + " -f, --format=FORMAT set output formatting to FORMAT\n" + " (\"table\", \"html\", \"csv\", " + "or \"json\")\n" + " -d, --data=FORMAT set table cell output formatting to\n" + " FORMAT (\"string\", \"bare\", " + "or \"json\")\n" + " --no-headings omit table heading row\n" + " --pretty pretty-print JSON in output\n" + " --bare equivalent to " + "\"--format=list --data=bare --no-headings\"\n"); +} diff --git a/lib/table.h b/lib/table.h index 7330a33c1..fee36897f 100644 --- a/lib/table.h +++ b/lib/table.h @@ -121,5 +121,6 @@ void table_parse_format(struct table_style *, const char *format); void table_parse_cell_format(struct table_style *, const char *format); void table_print(const struct table *, const struct table_style *); +void table_usage(void); #endif /* table.h */ diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index ebb9349dc..598f502af 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -448,6 +448,7 @@ Options:\n\ --oneline print exactly one line of output per command\n", program_name, program_name, ctl_get_db_cmd_usage(), default_nb_db()); + table_usage(); vlog_usage(); printf("\ --no-syslog equivalent to --verbose=nbctl:syslog:warn\n"); diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c index 4e3cbadac..ffa931ae1 100644 --- a/ovn/utilities/ovn-sbctl.c +++ b/ovn/utilities/ovn-sbctl.c @@ -327,6 +327,7 @@ Options:\n\ --oneline print exactly one line of output per command\n", program_name, program_name, ctl_get_db_cmd_usage(), default_sb_db()); + table_usage(); vlog_usage(); printf("\ --no-syslog equivalent to --verbose=sbctl:syslog:warn\n"); diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index ba232fce1..1df4fb4da 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -282,13 +282,8 @@ usage(void) "The default DATABASE is Open_vSwitch.\n", program_name, program_name, ovs_rundir()); stream_usage("SERVER", true, true, true); - printf("\nOutput formatting options:\n" - " -f, --format=FORMAT set output formatting to FORMAT\n" - " (\"table\", \"html\", \"csv\", " - "or \"json\")\n" - " --no-headings omit table heading row\n" - " --pretty pretty-print JSON in output\n" - " --timestamp timestamp \"monitor\" output"); + table_usage(); + printf(" --timestamp timestamp \"monitor\" output"); daemon_usage(); vlog_usage(); printf("\nOther options:\n" diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 4d9845e6a..84176dea9 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -421,6 +421,7 @@ Options:\n\ --dry-run do not commit changes to database\n\ --oneline print exactly one line of output per command\n", program_name, program_name, ctl_get_db_cmd_usage(), ctl_default_db()); + table_usage(); vlog_usage(); printf("\ --no-syslog equivalent to --verbose=vsctl:syslog:warn\n"); diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index e23c987da..7dc3cc775 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -366,6 +366,7 @@ Options:\n\ --dry-run do not commit changes to database\n\ --oneline print exactly one line of output per command\n", program_name, program_name, ctl_get_db_cmd_usage(), ctl_default_db()); + table_usage(); vlog_usage(); printf("\ --no-syslog equivalent to --verbose=vtep_ctl:syslog:warn\n"); -- 2.39.2