mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +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.
29 lines
453 B
Rust
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);
|
|
}
|