diff options
Diffstat (limited to 'third_party/rust/clap/examples/cargo-example-derive.rs')
-rw-r--r-- | third_party/rust/clap/examples/cargo-example-derive.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/third_party/rust/clap/examples/cargo-example-derive.rs b/third_party/rust/clap/examples/cargo-example-derive.rs new file mode 100644 index 0000000000..1ee0a02551 --- /dev/null +++ b/third_party/rust/clap/examples/cargo-example-derive.rs @@ -0,0 +1,22 @@ +// Note: this requires the `derive` feature + +use clap::Parser; + +#[derive(Parser)] +#[clap(name = "cargo")] +#[clap(bin_name = "cargo")] +enum Cargo { + ExampleDerive(ExampleDerive), +} + +#[derive(clap::Args)] +#[clap(author, version, about, long_about = None)] +struct ExampleDerive { + #[clap(long, parse(from_os_str))] + manifest_path: Option<std::path::PathBuf>, +} + +fn main() { + let Cargo::ExampleDerive(args) = Cargo::parse(); + println!("{:?}", args.manifest_path); +} |