clap/examples/22_stop_parsing_with_--.rs

26 lines
670 B
Rust
Raw Normal View History

2017-05-31 19:41:54 +00:00
extern crate clap;
use clap::{App, Arg};
/// myprog -f -p=bob -- sloppy slop slop
fn main() {
let matches = App::new("myprog")
.arg(Arg::with_name("eff")
.short("f"))
.arg(Arg::with_name("pea")
.short("p")
.takes_value(true))
.arg(Arg::with_name("slop")
2017-06-23 05:49:40 +00:00
.multiple(true)
.last(true))
2017-05-31 19:41:54 +00:00
.get_matches();
println!("-f used: {:?}", matches.is_present("eff"));
println!("-p's value: {:?}", matches.value_of("pea"));
println!("'slops' values: {:?}", matches.values_of("slop").map(|vals| vals.collect::<Vec<_>>()));
// Continued program logic goes here...
}