2022-02-11 07:07:03 -06:00
|
|
|
// Note: this requires the `cargo` feature
|
|
|
|
|
2021-12-15 11:33:10 -06:00
|
|
|
fn main() {
|
2022-02-14 15:47:20 -06:00
|
|
|
let cmd = clap::Command::new("cargo")
|
2021-12-15 11:33:10 -06:00
|
|
|
.bin_name("cargo")
|
2022-02-10 11:51:40 -06:00
|
|
|
.subcommand_required(true)
|
2021-12-15 11:33:10 -06:00
|
|
|
.subcommand(
|
2022-02-15 08:33:38 -06:00
|
|
|
clap::command!("example").arg(
|
2021-12-15 11:33:10 -06:00
|
|
|
clap::arg!(--"manifest-path" <PATH>)
|
|
|
|
.required(false)
|
2022-05-23 10:50:11 -05:00
|
|
|
.value_parser(clap::value_parser!(std::path::PathBuf)),
|
2021-12-15 11:33:10 -06:00
|
|
|
),
|
|
|
|
);
|
2022-02-14 15:47:20 -06:00
|
|
|
let matches = cmd.get_matches();
|
2021-12-15 11:33:10 -06:00
|
|
|
let matches = match matches.subcommand() {
|
|
|
|
Some(("example", matches)) => matches,
|
|
|
|
_ => unreachable!("clap should ensure we don't get here"),
|
|
|
|
};
|
2022-05-23 10:50:11 -05:00
|
|
|
let manifest_path = matches.get_one::<std::path::PathBuf>("manifest-path");
|
2021-12-15 11:33:10 -06:00
|
|
|
println!("{:?}", manifest_path);
|
|
|
|
}
|