diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-06-06 00:07:03 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-06-06 00:07:03 +0200 |
| commit | a101330c4197f3b6bb52d6bc105ba83004cd01e4 (patch) | |
| tree | a97b823e52261b2164aed409ee914623300c5668 | |
| parent | f32da6a6ef96eedb5c5125e3415fc38ff2e15663 (diff) | |
| download | tabular-a101330c4197f3b6bb52d6bc105ba83004cd01e4.tar.gz tabular-a101330c4197f3b6bb52d6bc105ba83004cd01e4.zip | |
Add options for lpad, rpad and header style
| m--------- | lib/libtabular | 0 | ||||
| -rw-r--r-- | main.c | 14 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/libtabular b/lib/libtabular -Subproject 8c27dfa1a6bcbfee1f40db689f53bcf204a207b +Subproject c8a02eac6a5c17087b5f0c64f4b3d732bb16649 @@ -27,6 +27,7 @@ static const struct allocator *ga = &stdlib_strict_heap_allocator; static bool hide_empty = false; static bool skip_empty_lines = true; static bool skip_empty_entries = false; +static bool header_underline = false; static char entry_sep = '\t'; static char line_sep = '\n'; @@ -99,6 +100,8 @@ print_style(FILE *file, const struct tabular_cfg *cfg, return true; } else if (!row) { /* header */ fprintf(file, "\x1b[1m"); + if (header_underline) + fprintf(file, "\x1b[4m"); return true; } } @@ -246,6 +249,14 @@ parse(int argc, const char **argv) } else if (!strcmp(*arg, "--xsep")) { if (!*++arg) die("missing args"); cfg.xsep = *arg; + } else if (!strcmp(*arg, "--lpad")) { + if (!*++arg) die("missing args"); + cfg.lpad = strtoul(*arg, &end, 10); + if (end && *end) die("bad %s", arg[-1]); + } else if (!strcmp(*arg, "--rpad")) { + if (!*++arg) die("missing args"); + cfg.rpad = strtoul(*arg, &end, 10); + if (end && *end) die("bad %s", arg[-1]); } else if (!strcmp(*arg, "--fit-rows")) { if (!*++arg) die("missing args"); cfg.fit_rows = bool_arg(*arg, "--fit-rows"); @@ -272,6 +283,9 @@ parse(int argc, const char **argv) if (!*++arg || !**arg || *(*arg+1)) die("missing args"); entry_sep = **arg; + } else if (!strcmp(*arg, "--header-underline")) { + if (!*++arg) die("missing args"); + header_underline = bool_arg(*arg, arg[-1]); } else if (!strcmp(*arg, "--skip-empty-entries")) { if (!*++arg) die("missing args"); skip_empty_entries = bool_arg(*arg, arg[-1]); |
