The design is inspired by clap-rs, which I used frequently.
The Arg
and Subcommand
are comptime functions accept a type and a config then generate a parser config. The clap.Parser
is to generate the parser code and a final data structure to hold the parsed value.
4 Likes
In case you haven’t seen it, there’s also
I know this library and also investigated some other libraries like:
- GitHub - prajwalch/yazap: 🔧 The ultimate Zig library for seamless command line parsing. Effortlessly handles options, subcommands, and custom arguments with ease.
- GitHub - ikskuh/zig-args: Simple-to-use argument parser with struct-based config
But I want a library:
- Support multiple level subcommand
- Support parse common types from string
- Define the parser as straightforward as possible
- Use the parsed result as simple as possible
Yes there are many arguments parsers in Zig, but none of them could match clap rs.
This is what I write before, i wonder if you like its syntax?
Although sub command is still not supported, but should be easy to implement.
FYI, I draft a design for subcommands here:
1 Like
Update, subcommands is supported, usage can be seen here:
I have one with sub commands too https://github.com/travisstaloch/clarp
1 Like
Thanks for share, it seems clarp share same design with simargs, which is to use a config struct/union to represent what to parse.
Glad to see projects taking full advantages of Zig’s comptime.
1 Like