Yet another argument parser for rust
- Rust 100%
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
no_std_args - A #[no_std] command-line argument parser for rust.
See crate documentation for more details.
Example:
use no_std_args::*;
label! {
Funny = "funny";
Sad = "sad";
Name = "<name>";
Extras = "<extras>";
}
let cmd = const {
Command::new()
.with_switch(Switch::short('f').with_long("funny").with_label(Funny))
.with_switch(Switch::short('s').with_label(Sad))
.with_argument(Positional::new().optional().with_label(Name))
.with_argument(Remainder::new().with_label(Extras))
};
let result = cmd.process(["cmd", "-s", "giuseppe", "and", "friends"]).unwrap();
assert_eq!(*result.get(Funny), false);
assert_eq!(*result.get(Sad), true);
assert_eq!(*result.get(Name), Some("giuseppe"));
assert_eq!(*result.get(Extras), ["and", "friends"]);