clap/clap_derive/examples/enum_tuple.rs
Ed Page 60c9c2e59a docs(derive): Use more-specific traits
This helps to raise visibility of the new derive traits.

I didn't touch ui tests because there were a lot and they didn't seem to
be as high value.
2021-10-12 07:51:11 -05:00

26 lines
488 B
Rust

//! How to extract subcommands' args into external structs.
use clap::{Args, Parser, Subcommand};
#[derive(Debug, Args)]
pub struct Foo {
pub bar: Option<String>,
}
#[derive(Debug, Subcommand)]
pub enum Command {
#[clap(name = "foo")]
Foo(Foo),
}
#[derive(Debug, Parser)]
#[clap(name = "classify")]
pub struct ApplicationArguments {
#[clap(subcommand)]
pub command: Command,
}
fn main() {
let opt = ApplicationArguments::parse();
println!("{:?}", opt);
}