๐ zli A blazing-fast, zero-cost CLI framework for Zig. The last one you will ever use. Build modular, ergonomic, and high-performance CLIs with ease. All batteries included. ๐งฑ Each command is modular and self-contained. inspired by Cobra (Go) and clap (Rust). ๐ Documentation See docs.md for full usage, examples, and internals. ๐ Highlights Modular commands & subcommands Fast flag parsing ( --flag , --flag=value , shorthand -abc ) , , shorthand ) Type-safe support for bool , int , string , , Named positional arguments with required , optional , variadic , , Auto help/version/deprecation handling Pretty help output with aligned flags & args Cobra-like usage hints, context-aware ๐ฆ Installation zig fetch --save=zli https://github.com/xcaeser/zli/archive/v3.5.1.tar.gz Add to your build.zig : const zli_dep = b . dependency ( "zli" , .{ . target = target }); exe . root_module . addImport ( "zli" , zli_dep . module ( "zli" )); ๐ Suggested Structure your-app/ โโโ build.zig โโโ src/ โ โโโ main.zig โ โโโ cli/ โ โโโ root.zig โ โโโ run.zig โ โโโ version.zig Each command is in its own file You explicitly register subcommands root.zig is the entry point ๐งช Example // src/main.zig const std = @import ( "std" ); const cli = @import ( "cli/root.zig" ); pub fn main () ! void { const allocator = std . heap . smp_allocator ; var root = try cli . build ( allocator ); defer root . deinit (); try root . execute (.{}); // Or pass data with: try root.execute(.{ .data = &my_data }); } // src/cli/root.zig const std = @import ( "std" ); const zli = @import ( "zli" ); const run = @import ( "run.zig" ); const version = @import ( "version.zig" ); pub fn build ( allocator : std.mem.Allocator ) ! * zli.Command { const root = try zli . Command . init ( allocator , .{ . name = "blitz" , . description = "Your dev toolkit CLI" , }, showHelp ); try root . addCommands (&.{ try run . register ( allocator ), try version . register ( allocator ), }); return root ; } fn showHelp ( ctx : zli.CommandContext ) ! ...
First seen: 2025-05-25 18:45
Last seen: 2025-05-25 21:45