A clap-rs inspired command line argument parser design for zig

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.


In case you haven’t seen it, there’s also

I know this library and also investigated some other libraries like:

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: