getargs-0.1.0 has been yanked.
getargs
An argument parser that is truly zero-cost, similar to getopts.
Example usage:
fn parse_args(args: &[String]) -> MyArgsStruct {
let mut res = MyArgsStruct::default();
let mut opts = getargs::Options::new(args);
while let Some(opt) = opts.next() {
match opt? {
Opt::Short('a') | Opt::Long("attack") => res.attack_mode = true,
Opt::Short('b') => res.suppress_bees = true,
Opt::Short('\u{2014}') => res.em_dashes = true,
Opt::Short('e') | Opt::Long("execute") => res.execute = opts.arg()?,
opt => return Err(Error::UnknownOpt(opt)),
}
}
}
fn main() {
let args = std::env::args();
let options = parse_args(&args);
}
Features
- Zero cost
- Zero dependencies
- Zero unsafe code
- Simple to use yet versatile
License
MIT.