1use clap::Parser;
2
3#[derive(Parser)] // requires `derive` feature
4#[command(author, version, about, long_about = None)]
5struct Cli {
6 #[arg(short = 'f')]
7 eff: bool,
8
9 #[arg(short = 'p', value_name = "PEAR")]
10 pea: Option<String>,
11
12 #[arg(last = true)]
13 slop: Vec<String>,
14}
15
16fn main() {
17 let args = Cli::parse();
18
19 // This is what will happen with `myprog -f -p=bob -- sloppy slop slop`...
20 println!("-f used: {:?}", args.eff); // -f used: true
21 println!("-p's value: {:?}", args.pea); // -p's value: Some("bob")
22 println!("'slops' values: {:?}", args.slop); // 'slops' values: Some(["sloppy", "slop", "slop"])
23
24 // Continued program logic goes here...
25}
26