2017-05-31 19:41:54 +00:00
|
|
|
use clap::{App, Arg};
|
|
|
|
|
|
|
|
/// myprog -f -p=bob -- sloppy slop slop
|
|
|
|
fn main() {
|
|
|
|
let matches = App::new("myprog")
|
2020-05-14 20:50:56 +00:00
|
|
|
.arg(Arg::new("eff").short('f'))
|
|
|
|
.arg(Arg::new("pea").short('p').takes_value(true))
|
2021-02-24 15:07:57 +00:00
|
|
|
.arg(Arg::new("slop").takes_value(true).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"));
|
2018-01-25 04:05:05 +00:00
|
|
|
println!(
|
|
|
|
"'slops' values: {:?}",
|
|
|
|
matches
|
|
|
|
.values_of("slop")
|
|
|
|
.map(|vals| vals.collect::<Vec<_>>())
|
|
|
|
);
|
2017-05-31 19:41:54 +00:00
|
|
|
|
|
|
|
// Continued program logic goes here...
|
|
|
|
}
|