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
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);
}
}
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 */
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");
TS_HELPER_LIBMOUNT_UTILS="$top_builddir/test_mount_utils"
TS_HELPER_LIBMOUNT_DEBUG="$top_builddir/test_mount_debug"
TS_HELPER_LIBSMARTCOLS_FROMFILE="$top_builddir/sample-scols-fromfile"
+TS_HELPER_LIBSMARTCOLS_TITLE="$top_builddir/sample-scols-title"
TS_HELPER_PYLIBMOUNT_CONTEXT="$top_srcdir/libmount/python/test_mount_context.py"
TS_HELPER_PYLIBMOUNT_TAB="$top_srcdir/libmount/python/test_mount_tab.py"
TS_HELPER_PYLIBMOUNT_UPDATE="$top_srcdir/libmount/python/test_mount_tab_update.py"
--- /dev/null
+ This is right title
+NAME DATA
+foo bla bla bla
+bar alb alb alb
+=======================This is center title (with padding)======================
+NAME DATA
+foo bla bla bla
+bar alb alb alb
+This is left title (with padding)-----------------------------------------------
+NAME DATA
+foo bla bla bla
+bar alb alb alb
--- /dev/null
+#!/bin/bash
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="title"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+TESTPROG="$TS_HELPER_LIBSMARTCOLS_TITLE"
+ts_check_test_command "$TESTPROG"
+
+$TESTPROG --width 80 >> $TS_OUTPUT 2>&1
+
+ts_finalize