summaryrefslogtreecommitdiffstats
path: root/libsmartcols/samples/title.c
diff options
context:
space:
mode:
authorKarel Zak2016-09-14 12:49:46 +0200
committerKarel Zak2016-09-14 12:49:46 +0200
commit36eb51ebb420e88b3147b652d08c21728d5c4f87 (patch)
treedbdebcc00f314b2cf318b71bc1b73d7a633f062a /libsmartcols/samples/title.c
parenttests: add another libsmartcols tests (diff)
downloadkernel-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/samples/title.c')
-rw-r--r--libsmartcols/samples/title.c19
1 files changed, 19 insertions, 0 deletions
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");