tabular

Flexible input tabulator
git clone https://git.sinitax.com/sinitax/tabular
Log | Files | Refs | Submodules | sfeed.txt

commit a101330c4197f3b6bb52d6bc105ba83004cd01e4
parent f32da6a6ef96eedb5c5125e3415fc38ff2e15663
Author: Louis Burda <quent.burda@gmail.com>
Date:   Tue,  6 Jun 2023 00:07:03 +0200

Add options for lpad, rpad and header style

Diffstat:
Mmain.c | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/main.c b/main.c @@ -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]);