Show HN: Zli – A Batteries-Included CLI Framework for Zig

18 caeser 2 5/25/2025, 4:52:14 PM github.com ↗
I built zli, a batteries-included CLI framework for Zig with a focus on DX and composability.

Key features:

- Typed flags with default values and help output - Rich formatting, and layout support - Command trees with isolated execution logic - It’s designed to feel good to use, not just to work. - Built for real-world CLI apps, not toy examples.

Would love feedback, feature ideas, or thoughts from other Zig devs.

repo here: https://github.com/xcaeser/zli

Comments (2)

90s_dev · 9m ago
Looks like a good zig argparse lib.

How do you like Zig compared to TypeScript? What would you like to see improved?

quotemstr · 20m ago
No terminfo support? I'm probably tilting at windmills here, but I wish people wouldn't hardcode terminal escape codes. Considering zig's good interop with C, wiring up a call to tigetstr().

It's also important not to emit escape codes at all when TERM=dumb. (You'll get this behavior automatically if you implement color support by asking terminfo to the escape codes.)

    const c = @cImport({
        @cInclude("ncurses.h");
        @cInclude("term.h");
    });

    pub fn main() !void {
        // Initialize terminfo
        _ = c.setupterm(null, 1, null);

        // Get capability strings
        const setaf = c.tigetstr("setaf");  // set foreground
        const setab = c.tigetstr("setab");  // set background
        const sgr0 = c.tigetstr("sgr0");    // reset

        // Parameterize for red foreground
        const red = c.tparm(setaf, c.COLOR_RED, 0, 0, 0, 0, 0, 0, 0, 0);

        // Use it
        _ = c.printf("%sThis is red%s\n", red, sgr0);
    }