diff options
author | Karel Zak <kzak@redhat.com> | 2016-01-22 13:46:29 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2016-01-22 13:46:29 +0100 |
commit | 6f2737964d57b55994ff59237903737dde7e8bdd (patch) | |
tree | 12083fb1007aa66b1736cfdf092cc29f8fde8b02 /libsmartcols | |
parent | 500a229f512fd78d51c3044c1a72067291530f7f (diff) | |
download | util-linux-6f2737964d57b55994ff59237903737dde7e8bdd.tar.gz |
libsmartcols: add JSON to the test application
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols')
-rw-r--r-- | libsmartcols/src/test.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libsmartcols/src/test.c b/libsmartcols/src/test.c index dd87fd38b..5b2cc6433 100644 --- a/libsmartcols/src/test.c +++ b/libsmartcols/src/test.c @@ -147,6 +147,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(" -l, --list use list format output\n", out); fputs(" -n, --noheadings don't print headings\n", out); fputs(" -p, --pairs use key=\"value\" output format\n", out); + fputs(" -J, --json use JSON output format\n", out); fputs(" -r, --raw use raw output format\n", out); exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); @@ -163,7 +164,8 @@ int main(int argc, char *argv[]) { "list", 0, 0, 'l' }, { "noheadings", 0, 0, 'n' }, { "pairs", 0, 0, 'p' }, - { "raw", 0, 0, 'r' }, + { "json", 0, 0, 'J' }, + { "raw", 0, 0, 'r' }, { NULL, 0, 0, 0 }, }; @@ -176,7 +178,7 @@ int main(int argc, char *argv[]) if (!tb) err(EXIT_FAILURE, "faild to create output table"); - while((c = getopt_long(argc, argv, "cilnpr", longopts, NULL)) != -1) { + while((c = getopt_long(argc, argv, "ciJlnpr", longopts, NULL)) != -1) { switch(c) { case 'c': scols_table_set_column_separator(tb, ","); @@ -186,6 +188,10 @@ int main(int argc, char *argv[]) case 'i': scols_table_enable_ascii(tb, 1); break; + case 'J': + scols_table_set_name(tb, "scolstest"); + scols_table_enable_json(tb, 1); + break; case 'l': notree = 1; break; |