Macro argwerk::args

source ·
macro_rules! args {
    (
        $(#[doc = $doc:literal])*
        $usage:literal { $($body:tt)* }
        $($config:tt)*
    ) => { ... };
}
Expand description

Works the same as define, but immediately parses arguments from std::env::args in place.

§Examples

let args = argwerk::args! {
    /// A simple test command.
    "command [-h]" {
        help: bool,
        limit: usize = 10,
    }
    /// Print this help.
    ["-h" | "--help"] => {
        help = true;
    }
}?;

if args.help {
    println!("{}", args.help());
}