arg-kit 1.0.1

A featherweight toolkit to help iterate long/short arguments
Documentation
  • Coverage
  • 60%
    9 out of 15 items documented0 out of 7 items with examples
  • Size
  • Source code size: 22.51 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.77 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • 64-Tesseract

arg-kit is a featherweight library that helps parse arguments using one of Rust's most versatile and powerful syntaxes: match {}

Do you really need bloated proc macros when collecting arguments can be simplified to a .next()? You have zero indication of what's going on under the hood, so you can't implement your own behaviour.

That is why I don't call it an "argument parser" on its own. Your program parses the arguments, this just helps iterate over it, like so:

let mut argv = std::env::args();
for_args!(argv; {
    arg!(-h | --help) => eprintln!("{HELP_TEXT}"),
    arg!(-v | --value) => do_something(argv.next()?),
    unknown => panic!("Unknown argument {unknown}"),
});

...which expands to:

let mut argv = std::env::args();
while let Some(args) = argv.next() {
    for arg in args.as_arg() {
        match arg {
            ...

Take a look through the docs for specific details. The sauce is hosted on my website because GitHub is gay.