2021-12-15 17:33:10 +00:00
|
|
|
fn main() {
|
2022-02-14 21:47:20 +00:00
|
|
|
let cmd = clap::Command::new("cargo")
|
2021-12-15 17:33:10 +00:00
|
|
|
.bin_name("cargo")
|
2024-08-08 15:31:27 +00:00
|
|
|
.styles(CLAP_STYLING)
|
2022-02-10 17:51:40 +00:00
|
|
|
.subcommand_required(true)
|
2021-12-15 17:33:10 +00:00
|
|
|
.subcommand(
|
2022-02-15 14:33:38 +00:00
|
|
|
clap::command!("example").arg(
|
2021-12-15 17:33:10 +00:00
|
|
|
clap::arg!(--"manifest-path" <PATH>)
|
2022-05-23 15:50:11 +00:00
|
|
|
.value_parser(clap::value_parser!(std::path::PathBuf)),
|
2021-12-15 17:33:10 +00:00
|
|
|
),
|
|
|
|
);
|
2022-02-14 21:47:20 +00:00
|
|
|
let matches = cmd.get_matches();
|
2021-12-15 17:33:10 +00:00
|
|
|
let matches = match matches.subcommand() {
|
|
|
|
Some(("example", matches)) => matches,
|
|
|
|
_ => unreachable!("clap should ensure we don't get here"),
|
|
|
|
};
|
2022-05-23 15:50:11 +00:00
|
|
|
let manifest_path = matches.get_one::<std::path::PathBuf>("manifest-path");
|
2023-05-04 19:53:36 +00:00
|
|
|
println!("{manifest_path:?}");
|
2021-12-15 17:33:10 +00:00
|
|
|
}
|
2024-08-08 15:31:27 +00:00
|
|
|
|
|
|
|
// 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);
|