clap/clap_derive/examples/flatten.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

29 lines
453 B
Rust

//! How to use flattening.
use clap::{Args, Parser};
#[derive(Parser, Debug)]
struct Cmdline {
/// switch verbosity on
#[clap(short)]
verbose: bool,
#[clap(flatten)]
daemon_opts: DaemonOpts,
}
#[derive(Args, Debug)]
struct DaemonOpts {
/// daemon user
#[clap(short)]
user: String,
/// daemon group
#[clap(short)]
group: String,
}
fn main() {
let opt = Cmdline::parse();
println!("{:?}", opt);
}