Debian Codegraph @

debian/missing-sources/clap/examples/cargo-example.rs

raw
1 fn main() {
2 let cmd = clap::Command::new("cargo")
3 .bin_name("cargo")
4 .styles(CLAP_STYLING)
5 .subcommand_required(true)
6 .subcommand(
7 clap::command!("example").arg(
8 clap::arg!(--"manifest-path" <PATH>)
9 .value_parser(clap::value_parser!(std::path::PathBuf)),
10 ),
11 );
12 let matches = cmd.get_matches();
13 let matches = match matches.subcommand() {
14 Some(("example", matches)) => matches,
15 _ => unreachable!("clap should ensure we don't get here"),
16 };
17 let manifest_path = matches.get_one::<std::path::PathBuf>("manifest-path");
18 println!("{manifest_path:?}");
19 }
20
21 // See also `clap_cargo::style::CLAP_STYLING`
22 pub const CLAP_STYLING: clap::builder::styling::Styles = clap::builder::styling::Styles::styled()
23 .header(clap_cargo::style::HEADER)
24 .usage(clap_cargo::style::USAGE)
25 .literal(clap_cargo::style::LITERAL)
26 .placeholder(clap_cargo::style::PLACEHOLDER)
27 .error(clap_cargo::style::ERROR)
28 .valid(clap_cargo::style::VALID)
29 .invalid(clap_cargo::style::INVALID);