diff options
Diffstat (limited to 'clap/examples/22_stop_parsing_with_--.rs')
-rw-r--r-- | clap/examples/22_stop_parsing_with_--.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clap/examples/22_stop_parsing_with_--.rs b/clap/examples/22_stop_parsing_with_--.rs new file mode 100644 index 0000000..a5ba5b3 --- /dev/null +++ b/clap/examples/22_stop_parsing_with_--.rs @@ -0,0 +1,25 @@ +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") + .multiple(true) + .last(true)) + .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... +} |