argwerk

Documentation Crates Actions Status

Helper utility for parsing simple commandline arguments.

This is not intended to be a complete commandline parser library. Instead this can be used as an alternative quick-and-dirty approach that can be cheaply incorporated into a tool.

For a more complete commandline parsing library, use [clap].

See the documentation for [argwerk::parse!] for how to use.

Examples

This is available as a runnable example: sh cargo run --example tour

```rust let args = argwerk::parse! { /// A simple test command. /// /// This is nice! "testcommand [-h]" { help: bool, file: Option, limit: usize = 42, positional: Option<(String, Option)>, rest: Vec, } /// Print this help. "-h" | "--help" => { help = true; printhelp(); Ok(()) } /// Limit the number of things by . "--limit" | "-l", n => { limit = str::parse(&n)?; Ok(()) } /// Write to the file specified by . "--file", path if !file.issome() => { file = Some(path); Ok(()) } /// Takes argument at and . (foo, #[option] bar, #[rest] args) if positional.is_none() => { positional = Some((foo, bar)); rest = args; Ok(()) } }?;

dbg!(args); ```

License: MIT/Apache-2.0