summaryrefslogtreecommitdiffstats
path: root/libsmartcols/samples/fromfile.c
diff options
context:
space:
mode:
authorKarel Zak2016-09-16 13:49:37 +0200
committerKarel Zak2016-09-16 13:49:37 +0200
commit4a2b50f2384f8fb6cec941c1483d1c60003671ee (patch)
tree731d07a15960f48db262d73f903a26819e08ca3e /libsmartcols/samples/fromfile.c
parenttests: add libsmartcols JSON test (diff)
downloadkernel-qcow2-util-linux-4a2b50f2384f8fb6cec941c1483d1c60003671ee.tar.gz
kernel-qcow2-util-linux-4a2b50f2384f8fb6cec941c1483d1c60003671ee.tar.xz
kernel-qcow2-util-linux-4a2b50f2384f8fb6cec941c1483d1c60003671ee.zip
tests: add export and raw to libsmartcols test
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/samples/fromfile.c')
-rw-r--r--libsmartcols/samples/fromfile.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/libsmartcols/samples/fromfile.c b/libsmartcols/samples/fromfile.c
index e33cb3c9a..6b9748897 100644
--- a/libsmartcols/samples/fromfile.c
+++ b/libsmartcols/samples/fromfile.c
@@ -17,6 +17,7 @@
#include "nls.h"
#include "strutils.h"
#include "xalloc.h"
+#include "optutils.h"
#include "libsmartcols.h"
@@ -195,6 +196,8 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
fputs(" -c, --column <file> column definition\n", out);
fputs(" -n, --nlines <num> number of lines\n", out);
fputs(" -J, --json JSON output format\n", out);
+ fputs(" -r, --raw RAW output format\n", out);
+ fputs(" -E, --export use key=\"value\" output format\n", out);
fputs(" -w, --width <num> hardcode terminal width\n", out);
fputs(" -p, --tree-parent-column <n> parent column\n", out);
fputs(" -i, --tree-id-column <n> id column\n", out);
@@ -218,19 +221,29 @@ int main(int argc, char *argv[])
{ "tree-parent-column", 1, 0, 'p' },
{ "tree-id-column", 1, 0, 'i' },
{ "json", 0, 0, 'J' },
+ { "raw", 0, 0, 'r' },
+ { "export", 0, 0, 'E' },
{ "help", 0, 0, 'h' },
{ NULL, 0, 0, 0 },
};
- setlocale(LC_ALL, ""); /* just to have enable UTF8 chars */
+ static const ul_excl_t excl[] = { /* rows and cols in in ASCII order */
+ { 'E', 'J', 'r' },
+ { 0 }
+ };
+ int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
+ setlocale(LC_ALL, ""); /* just to have enable UTF8 chars */
scols_init_debug(0);
tb = scols_new_table();
if (!tb)
err(EXIT_FAILURE, "failed to create output table");
- while((c = getopt_long(argc, argv, "hc:i:Jmn:p:w:", longopts, NULL)) != -1) {
+ while((c = getopt_long(argc, argv, "hc:Ei:Jmn:p:rw:", longopts, NULL)) != -1) {
+
+ err_exclusive_options(c, longopts, excl, excl_st);
+
switch(c) {
case 'c': /* add column from file */
{
@@ -259,6 +272,12 @@ int main(int argc, char *argv[])
case 'm':
scols_table_enable_maxout(tb, TRUE);
break;
+ case 'r':
+ scols_table_enable_raw(tb, TRUE);
+ break;
+ case 'E':
+ scols_table_enable_export(tb, TRUE);
+ break;
case 'n':
nlines = strtou32_or_err(optarg, "failed to parse number of lines");
break;