]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: add --{export,raw,json} to wrap sample
authorKarel Zak <kzak@redhat.com>
Thu, 19 Oct 2023 10:42:35 +0000 (12:42 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 23 Oct 2023 19:54:00 +0000 (21:54 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/samples/wrap.c

index 795bef7140630dd75c25552f9ce9f1f172bda599..836830402d2582c39f882597337124badebe792d 100644 (file)
@@ -92,7 +92,15 @@ int main(int argc, char *argv[])
        if (!tb)
                err(EXIT_FAILURE, "failed to create output table");
 
-       scols_table_enable_colors(tb, isatty(STDOUT_FILENO));
+       if (argc > 1 && strcmp(argv[1], "--export") == 0)
+               scols_table_enable_export(tb, 1);
+       else if (argc > 1 && strcmp(argv[1], "--raw") == 0)
+               scols_table_enable_raw(tb, 1);
+       else if (argc > 1 && strcmp(argv[1], "--json") == 0)
+               scols_table_enable_json(tb, 1);
+       else
+               scols_table_enable_colors(tb, isatty(STDOUT_FILENO));
+
        setup_columns(tb);
 
        ln = add_line(tb, NULL, "A");