mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
24 lines
414 B
Rust
24 lines
414 B
Rust
|
use clap::Parser;
|
||
|
|
||
|
#[test]
|
||
|
fn test_safely_nest_parser() {
|
||
|
#[derive(Parser, Debug, PartialEq)]
|
||
|
struct Opt {
|
||
|
#[command(flatten)]
|
||
|
foo: Foo,
|
||
|
}
|
||
|
|
||
|
#[derive(Parser, Debug, PartialEq)]
|
||
|
struct Foo {
|
||
|
#[arg(long)]
|
||
|
foo: bool,
|
||
|
}
|
||
|
|
||
|
assert_eq!(
|
||
|
Opt {
|
||
|
foo: Foo { foo: true }
|
||
|
},
|
||
|
Opt::try_parse_from(&["test", "--foo"]).unwrap()
|
||
|
);
|
||
|
}
|