Files
tubestation/third_party/rust/clap/examples/cargo-example.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

30 lines
1.1 KiB
Rust

fn main() {
let cmd = clap::Command::new("cargo")
.bin_name("cargo")
.styles(CLAP_STYLING)
.subcommand_required(true)
.subcommand(
clap::command!("example").arg(
clap::arg!(--"manifest-path" <PATH>)
.value_parser(clap::value_parser!(std::path::PathBuf)),
),
);
let matches = cmd.get_matches();
let matches = match matches.subcommand() {
Some(("example", matches)) => matches,
_ => unreachable!("clap should ensure we don't get here"),
};
let manifest_path = matches.get_one::<std::path::PathBuf>("manifest-path");
println!("{manifest_path:?}");
}
// See also `clap_cargo::style::CLAP_STYLING`
pub const CLAP_STYLING: clap::builder::styling::Styles = clap::builder::styling::Styles::styled()
.header(clap_cargo::style::HEADER)
.usage(clap_cargo::style::USAGE)
.literal(clap_cargo::style::LITERAL)
.placeholder(clap_cargo::style::PLACEHOLDER)
.error(clap_cargo::style::ERROR)
.valid(clap_cargo::style::VALID)
.invalid(clap_cargo::style::INVALID);