2021-12-15 17:33:10 +00:00
|
|
|
use clap::Parser;
|
|
|
|
|
2022-07-19 18:29:31 +00:00
|
|
|
#[derive(Parser)] // requires `derive` feature
|
2022-09-02 20:37:23 +00:00
|
|
|
#[command(name = "cargo")]
|
|
|
|
#[command(bin_name = "cargo")]
|
2024-08-08 15:31:27 +00:00
|
|
|
#[command(styles = CLAP_STYLING)]
|
2023-02-06 16:25:14 +00:00
|
|
|
enum CargoCli {
|
|
|
|
ExampleDerive(ExampleDeriveArgs),
|
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);
|
|
|
|
|
2021-12-15 17:33:10 +00:00
|
|
|
#[derive(clap::Args)]
|
2024-01-17 14:06:56 +00:00
|
|
|
#[command(version, about, long_about = None)]
|
2023-02-06 16:25:14 +00:00
|
|
|
struct ExampleDeriveArgs {
|
2022-09-02 20:37:23 +00:00
|
|
|
#[arg(long)]
|
2021-12-15 17:33:10 +00:00
|
|
|
manifest_path: Option<std::path::PathBuf>,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2023-02-06 16:25:14 +00:00
|
|
|
let CargoCli::ExampleDerive(args) = CargoCli::parse();
|
2021-12-15 17:33:10 +00:00
|
|
|
println!("{:?}", args.manifest_path);
|
|
|
|
}
|