2021-12-09 01:25:48 +00:00
|
|
|
// Note: this requires the `derive` feature
|
2021-12-08 22:46:49 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
use clap::Parser;
|
|
|
|
|
|
|
|
#[derive(Parser)]
|
2022-01-11 00:47:20 +00:00
|
|
|
#[clap(author, version, about, long_about = None)]
|
2021-11-30 18:30:19 +00:00
|
|
|
struct Cli {
|
|
|
|
#[clap(short = 'f')]
|
|
|
|
eff: bool,
|
|
|
|
|
|
|
|
#[clap(short = 'p', value_name = "PEAR")]
|
|
|
|
pea: Option<String>,
|
|
|
|
|
|
|
|
#[clap(last = true)]
|
|
|
|
slop: Vec<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let args = Cli::parse();
|
|
|
|
|
|
|
|
// This is what will happen with `myprog -f -p=bob -- sloppy slop slop`...
|
|
|
|
println!("-f used: {:?}", args.eff); // -f used: true
|
|
|
|
println!("-p's value: {:?}", args.pea); // -p's value: Some("bob")
|
|
|
|
println!("'slops' values: {:?}", args.slop); // 'slops' values: Some(["sloppy", "slop", "slop"])
|
|
|
|
|
|
|
|
// Continued program logic goes here...
|
|
|
|
}
|