ZLI: the fast Zig CLI with nice DX

I bring to you today zli.

:high_voltage: A blazing fast, zero-cost Zig CLI framework inspired by Cobra and Clap. Build ergonomic, high-performance command-line tools with ease.

Coming from Go, i always liked how cobra helps with creating CLIs. now we have one in zig.

I hope it becomes famous because it’s so nice to use (if I do say so myself :stuck_out_tongue:)

Issues and pull requests are welcome! Please open an issue for bugs, feature requests, or questions as I am still discovering how awesome zig is!!

13 Likes

Hey! Always cool to see other CLI Libraries! I took a little inspiration from Cobra as well.

Just so you’re aware, there is another CLI library named ZLI (not mine). That’s not to say you can’t share the name. More just a heads up in case you wanted to have a unique name.

1 Like

shoot, didn’t know that.

i think i’ll leave it like that

v2.0.0 is LIVE!

Some friendly feedback:

  1. “Blazing fast”, consider performing benchmarks to justify this claim. Check out poop, it might be useful GitHub - andrewrk/poop: Performance Optimizer Observation Platform
  2. Have you considered adding tests? Here is a quick github action that can run your tests:
name: Tests
on:
  push:
  pull_request:
    branches:
      - main
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Setup Zig Compiler
        uses: mlugg/setup-zig@v1.2.1
        with:
          version: 0.14.0
      - name: Build and test Zig Project
        run: zig build test
11 Likes

Are there actually CLI parser libraries that end up being a performance bottleneck in any non-synthetic workloads?

4 Likes

No. I can’t think of a case that is less in need of optimization than parsing the CL.

3.1.2 published :slight_smile:

ALREADY AT 34 STARS!! :glowing_star: Thank you all

It’s getting better with each release.

!!! Zig is such a productive language.

1 Like

:rocket: zli v3.2.0 – Smarter, Safer, Faster CLI

Thank you for 42 stars :glowing_star:!

Major internal refactor with typed flags, better error handling, and faster parsing. zli is now safer to use and easier to extend.

:new_button: New

  • Typed Flag Values
    Flags now use a FlagValue type (Bool, Int, String) instead of raw strings. This makes value handling safer and clearer.
  • Type-Safe Flag Access
    Added ctx.flag("name", T) to retrieve flag values as the correct type with defaults built-in.
  • Built-in Flag Parsing Logic
    Each flag knows how to parse and validate its own value via .evaluateValueType() and .safeEvaluate().

:warning: Breaking Changes

  • Flag Storage Format Changed
    flag_values now stores typed values (FlagValue) instead of strings. Old get*Value() methods have been removed.
  • Access Patterns Updated
    You must now use ctx.flag("name", T) instead of getBoolValue, getIntValue, etc.

:wrench: Improvements

  • Smarter Flag Parsing
    Supports --flag=value, --flag value, -abc, and detects misuse (e.g. grouping non-bool flags).
    Better errors with clear explanations and usage hints.
  • Faster Flag Lookup
    Added direct lookup maps for flag shortcuts. No more iterating over all flags.
  • Better Errors & Help Output
    Clearer error messages and help prompts when a command or flag is misused.
  • Cleaner Internal APIs
    Simplified flag handling, command structure, and removed redundant logic.
2 Likes

updated one thank you!

name: Tests
on:
  push:
    paths:
      - "src/**"
      - "build.zig"
  pull_request:
    branches:
      - main
    paths:
      - "src/**"
      - "build.zig"
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Zig Compiler
        uses: mlugg/setup-zig@v2
        with:
          version: 0.14.1

      - name: Build and test ZLI
        run: zig build test --summary all

Shipped a new update Release v3.7.0 · xcaeser/zli · GitHub

You’re gonna like this one: Spinners

worked hard on having powerful DX to add loading steps into the cli, updating current loading text, success&fail messsages etc…

zig continues to amaze me

1 Like