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")
|
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>)
|
|
|
|
.required(false)
|
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");
|
2021-12-15 17:33:10 +00:00
|
|
|
println!("{:?}", manifest_path);
|
|
|
|
}
|