arg-kit

Crates.ioarg-kit
lib.rsarg-kit
version1.0.1
sourcesrc
created_at2024-08-04 08:27:07.876051
updated_at2024-08-04 08:39:27.133676
descriptionA featherweight toolkit to help iterate long/short arguments
homepage
repositoryhttp://64-tesseract.us.to/projects#arg-kit
max_upload_size
id1324811
size22,990
(64-Tesseract)

documentation

README

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.

Commit count: 0

cargo fmt