diff options
author | Karel Zak | 2016-09-14 12:49:46 +0200 |
---|---|---|
committer | Karel Zak | 2016-09-14 12:49:46 +0200 |
commit | 36eb51ebb420e88b3147b652d08c21728d5c4f87 (patch) | |
tree | dbdebcc00f314b2cf318b71bc1b73d7a633f062a /libsmartcols | |
parent | tests: add another libsmartcols tests (diff) | |
download | kernel-qcow2-util-linux-36eb51ebb420e88b3147b652d08c21728d5c4f87.tar.gz kernel-qcow2-util-linux-36eb51ebb420e88b3147b652d08c21728d5c4f87.tar.xz kernel-qcow2-util-linux-36eb51ebb420e88b3147b652d08c21728d5c4f87.zip |
tests: add libsmartcols title test
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols')
-rw-r--r-- | libsmartcols/samples/Makemodule.am | 2 | ||||
-rw-r--r-- | libsmartcols/samples/fromfile.c | 2 | ||||
-rw-r--r-- | libsmartcols/samples/title.c | 19 |
3 files changed, 20 insertions, 3 deletions
diff --git a/libsmartcols/samples/Makemodule.am b/libsmartcols/samples/Makemodule.am index b44d888b4..0a54abbbf 100644 --- a/libsmartcols/samples/Makemodule.am +++ b/libsmartcols/samples/Makemodule.am @@ -18,7 +18,7 @@ sample_scols_tree_CFLAGS = $(sample_scols_cflags) endif sample_scols_title_SOURCES = libsmartcols/samples/title.c -sample_scols_title_LDADD = $(sample_scols_ldadd) +sample_scols_title_LDADD = $(sample_scols_ldadd) libcommon.la sample_scols_title_CFLAGS = $(sample_scols_cflags) sample_scols_wrap_SOURCES = libsmartcols/samples/wrap.c diff --git a/libsmartcols/samples/fromfile.c b/libsmartcols/samples/fromfile.c index ec12267a6..aa283ded5 100644 --- a/libsmartcols/samples/fromfile.c +++ b/libsmartcols/samples/fromfile.c @@ -194,8 +194,6 @@ int main(int argc, char *argv[]) scols_table_set_termforce(tb, SCOLS_TERMFORCE_ALWAYS); scols_table_set_termwidth(tb, strtou32_or_err(optarg, "failed to parse terminal width")); break; - default: - err(EXIT_FAILURE, "%s [-r|--random]\n", program_invocation_short_name); } } diff --git a/libsmartcols/samples/title.c b/libsmartcols/samples/title.c index 08cc2c621..852316095 100644 --- a/libsmartcols/samples/title.c +++ b/libsmartcols/samples/title.c @@ -57,6 +57,13 @@ int main(int argc, char *argv[]) struct libscols_table *tb; struct libscols_symbols *sy; struct libscols_cell *title; + int c; + + static const struct option longopts[] = { + { "maxout", 0, 0, 'm' }, + { "width", 1, 0, 'w' }, + { NULL, 0, 0, 0 }, + }; setlocale(LC_ALL, ""); /* just to have enable UTF8 chars */ @@ -66,6 +73,18 @@ int main(int argc, char *argv[]) if (!tb) err(EXIT_FAILURE, "failed to create output table"); + while((c = getopt_long(argc, argv, "mw:", longopts, NULL)) != -1) { + switch(c) { + case 'm': + scols_table_enable_maxout(tb, TRUE); + break; + case 'w': + scols_table_set_termforce(tb, SCOLS_TERMFORCE_ALWAYS); + scols_table_set_termwidth(tb, strtou32_or_err(optarg, "failed to parse terminal width")); + break; + } + } + scols_table_enable_colors(tb, isatty(STDOUT_FILENO)); setup_columns(tb); add_line(tb, "foo", "bla bla bla"); |