mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 15:22:30 +00:00
60c9c2e59a
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.
26 lines
488 B
Rust
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);
|
|
}
|