Files
tubestation/third_party/rust/clap/examples/escaped-positional-derive.rs
Ben Dean-Kawamura 98d9c11242 Bug 1915426 - Update clap/heck/darling/anstyle/strsim, r=glandium,supply-chain-reviewers
Updated:
  - heck 0.4.1 -> 0.5.0
  - clap 4.4.5 -> 4.5.16
  - darling v0.20.1 -> v0.20.10
  - strsim 0.10.0 -> 0.11.1
  - anstyle 1.0.3 -> 1.0.8

This is in preparation of the UniFFI 0.28 upgrade:
https://bugzilla.mozilla.org/show_bug.cgi?id=1914241

Differential Revision: https://phabricator.services.mozilla.com/D220437
2024-09-09 15:42:31 +00:00

26 lines
684 B
Rust

use clap::Parser;
#[derive(Parser)] // requires `derive` feature
#[command(version, about, long_about = None)]
struct Cli {
#[arg(short = 'f')]
eff: bool,
#[arg(short = 'p', value_name = "PEAR")]
pea: Option<String>,
#[arg(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...
}