mirror of
https://github.com/clap-rs/clap
synced 2024-12-16 07:42:32 +00:00
d3bf5450ff
Since the `name` is changed to be the package name, we can't use it as (1) its not as predictable and (2) it can lead to conflicts if a `Parser` is flattened into a `Parser`
23 lines
414 B
Rust
23 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()
|
|
);
|
|
}
|