1313[ ![ Zig Version] ( https://img.shields.io/badge/Zig-0.14.1-orange?logo=zig&labelColor=282c34 )] ( https://ziglang.org/download/ )
1414[ ![ Release] ( https://img.shields.io/github/release/habedi/chilli.svg?label=release&style=flat&labelColor=282c34&logo=github )] ( https://github.com/habedi/chilli/releases/latest )
1515
16- A mini framework for creating command line applications in Zig
16+ A microframework for creating command- line applications in Zig
1717
1818</div >
1919
2020---
2121
22- Chilli is a lightweight command line interface (CLI) framework for Zig programming language.
22+ Chilli is a lightweight command- line interface (CLI) framework for the Zig programming language.
2323Its goal is to make it easy to create structured, maintainable, and user-friendly CLIs with minimal boilerplate,
24- while being small and fast, and not get in the way of your application logic.
24+ while being small and fast, and not getting in the way of your application logic.
2525
26- > [ !IMPORTANT]
27- > Chilli is in the early stages of development and is not yet ready for serious use.
28- > The API is not stable and may change without notice.
26+ ### Features
2927
30- ### Feature Checklist
28+ - Provides a simple, declarative API for building CLI applications
29+ - Supports nested commands, subcommands, and aliases
30+ - Provides type-safe parsing for flags, positional arguments, and environment variables
31+ - Supports generating automatic ` --help ` and ` --version ` output with custom sections
32+ - Uses a shared context to pass application state
33+ - Written in pure Zig with no external dependencies
3134
32- - [x] ** Command Structure**
33- - [x] Nested commands and subcommands
34- - [x] Command aliases
35- - [x] Persistent flags (flags on parent commands are available to children)
36-
37- - [x] ** Argument & Flag Parsing**
38- - [x] Long flags (` --verbose ` ), short flags (` -v ` ), and grouped boolean flags (` -vf ` )
39- - [x] Type-safe flag access (like ` ctx.getFlag("count", i64) ` )
40- - [ ~ ] Positional Arguments (supports required & optional; no variadic support yet)
41-
42- - [x] ** Help & Usage Output**
43- - [x] Automatic and context-aware help generation (` --help ` )
44- - [x] Clean, aligned help output for commands, flags, and arguments
45- - [ ~ ] Version display (shows in help text; no automatic ` --version ` flag)
46-
47- - [x] ** Developer Experience**
48- - [x] Context data for passing application state
49- - [ ] Named access for positional arguments (access is currently by index)
50- - [ ] Deprecation notices for commands or flags
51- - [ ] Built-in TUI components (like spinners and progress bars)
35+ > [ !IMPORTANT]
36+ > Chilli is in early development and is not yet ready for serious use.
37+ > The API is not stable and may change without notice.
38+ > Please use the [ issues page] ( https://github.com/habedi/chilli/issues ) to report bugs or request features.
5239
5340---
5441
5542### Getting Started
5643
57- You can use Chilli by adding it as a dependency to your Zig project.
58- The Zig build system will download and cache it automatically.
44+ You can add Chilli to your project and start using it by following the steps below.
5945
60- #### 1. Add Chilli to ` build.zig.zon `
46+ #### Installation
6147
62- First, declare the ` chilli ` dependency in your ` build.zig.zon ` file.
63- You will need to provide the URL to a specific release tarball and its content hash.
48+ Run the following command in the root directory of your project to download Chilli:
6449
65- ``` zig
66- .{
67- .name = "your-cli-app",
68- .version = "0.1.0",
69- .minimum_zig_version = "0.14.1",
70- .dependencies = .{
71- .chilli = .{
72- // URL for the latest commit on the main branch
73- .url = "https://github.com/habedi/chilli/archive/main.tar.gz",
74- // The hash of that specific commit's content
75- .hash = "1220...", // Replace with the actual hash
76- },
77- },
78- .paths = .{
79- "build.zig",
80- "build.zig.zon",
81- "src",
82- },
83- }
50+ ``` sh
51+ zig fetch --save=chilli " https://github.com/habedi/chilli/archive/<branch_or_tag>.tar.gz"
8452```
8553
86- > [ !NOTE]
87- > To get the correct ` .hash ` value, you can first put a dummy value (like ` "122000" ` ) and run the ` zig build ` command.
88- > The compiler will fail, but it will print the expected hash value for you to copy and paste into the dependencies
89- > section to replace the dummy value.
54+ Replace ` <branch_or_tag> ` with the desired branch or tag, like ` main ` or ` v0.1.0 ` .
55+ This command will download Chilli and add it to Zig's global cache and update your project's ` build.zig.zon ` file.
9056
91- #### 2. Use the Dependency in ` build.zig `
57+ #### Adding to Build Script
9258
93- Next, modify your ` build.zig ` file to get the dependency from the builder and make it available to your executable as a
94- module.
59+ Next, modify your ` build.zig ` file to make Chilli available to your build target as a module.
9560
9661``` zig
9762const std = @import("std");
@@ -120,19 +85,18 @@ pub fn build(b: *std.Build) void {
12085}
12186```
12287
123- #### 3. Write Your Application Code
88+ #### Using Chilli in an Application
12489
125- Finally, you can ` @import("chilli") ` and start building your application in ` src/main.zig ` .
90+ Finally, you can ` @import("chilli") ` and start using it in your Zig application .
12691
12792``` zig
12893const std = @import("std");
12994const chilli = @import("chilli");
13095
13196// A function for our command to execute
13297fn greet(ctx: chilli.CommandContext) !void {
133- // getFlag is type-safe and panics on type mismatch
134- const name = ctx.getFlag("name", []const u8);
135- const excitement = ctx.getFlag("excitement", u32);
98+ const name = try ctx.getFlag("name", []const u8);
99+ const excitement = try ctx.getFlag("excitement", u32);
136100
137101 std.print("Hello, {s}", .{name});
138102 var i: u32 = 0;
@@ -159,7 +123,7 @@ pub fn main() anyerror!void {
159123 // Add flags to the command
160124 try root_cmd.addFlag(.{
161125 .name = "name",
162- .shortcut = "n" ,
126+ .shortcut = 'n' ,
163127 .description = "The name to greet",
164128 .type = .String,
165129 .default_value = .{ .String = "World" },
@@ -176,13 +140,54 @@ pub fn main() anyerror!void {
176140}
177141```
178142
143+ ---
144+
145+ ### Documentation
146+
147+ You can use the ` make doc ` command to generate the API documentation for Chilli.
148+ This will generate HTML documentation in the [ docs/api] ( docs/api/index.html ) directory, which you can serve locally with
149+ ` make serve-docs ` and view in your web browser at ` http://localhost:8000/index.html ` .
150+
179151### Examples
180152
181- | File | Description |
182- | -------------------------------------------| --------------------------------------------------------------------|
183- | [ simple_cli.zig] ( examples/simple_cli.zig ) | A simple CLI application that shows basic command and flag parsing |
153+ Here’s your table with an added ** Index** column:
154+
155+ | ** #** | ** File** | ** Description** |
156+ | -------| -------------------------------------------------------------| ---------------------------------------------------------------------|
157+ | 1 | [ e1\_ simple\_ cli.zig] ( examples/e1_simple_cli.zig ) | A simple CLI application that shows basic command and flag parsing |
158+ | 2 | [ e2\_ nested\_ commands.zig] ( examples/e2_nested_commands.zig ) | A CLI application with nested commands and subcommands |
159+ | 3 | [ e3\_ help\_ output.zig] ( examples/e3_help_output.zig ) | Example demonstrates automatic help output and usage information |
160+ | 4 | [ e4\_ flags\_ and\_ args.zig] ( examples/e4_flags_and_args.zig ) | Example shows how to use flags and positional arguments in commands |
161+ | 5 | [ e5\_ custom\_ sections.zig] ( examples/e5_custom_sections.zig ) | Example demonstrates grouping subcommands into custom sections |
162+ | 6 | [ e6\_ advanced\_ cli.zig] ( examples/e6_advanced_cli.zig ) | More advanced example that combines multiple features of Chilli |
163+
164+ ### Feature Checklist
184165
185- -----
166+ - [x] ** Command Structure**
167+ - [x] Nested commands and subcommands
168+ - [x] Command aliases and single-character shortcuts
169+ - [x] Persistent flags (flags on parent commands are available to children)
170+
171+ - [x] ** Argument & Flag Parsing**
172+ - [x] Long flags (` --verbose ` ), short flags (` -v ` ), and grouped boolean flags (` -vf ` )
173+ - [x] Positional Arguments (supports required, optional, and variadic)
174+ - [x] Type-safe access for flags and arguments (e.g., ` ctx.getFlag("count", i64) ` )
175+ - [x] Reading flag values from environment variables
176+
177+ - [x] ** Help & Usage Output**
178+ - [x] Automatic and context-aware ` --help ` flag
179+ - [x] Automatic ` --version ` flag
180+ - [x] Clean, aligned help output for commands, flags, and arguments
181+ - [x] Grouping subcommands into custom sections
182+
183+ - [x] ** Developer Experience**
184+ - [x] Simple, declarative API for building commands
185+ - [x] Named access for all flags and arguments
186+ - [x] Shared context data for passing application state
187+ - [ ] Deprecation notices for commands or flags
188+ - [ ] Built-in TUI components (like spinners and progress bars)
189+
190+ ---
186191
187192### Contributing
188193
0 commit comments