Skip to content

Commit

Permalink
test(derive): Show failure in clap-rs#4279
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 30, 2022
1 parent 6ca0569 commit 35eeba0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/derive/groups.rs
Expand Up @@ -21,3 +21,29 @@ fn test_safely_nest_parser() {
Opt::try_parse_from(&["test", "--foo"]).unwrap()
);
}

#[test]
#[should_panic = "'Compose' is already in use"]
fn skip_group_avoids_duplicate_ids() {
#[derive(Parser, Debug)]
struct Opt {
#[command(flatten)]
first: Compose<Empty, Empty>,
#[command(flatten)]
second: Compose<Empty, Empty>,
}

#[derive(clap::Args, Debug)]
pub struct Compose<L: clap::Args, R: clap::Args> {
#[clap(flatten)]
pub left: L,
#[clap(flatten)]
pub right: R,
}

#[derive(clap::Args, Clone, Copy, Debug)]
pub struct Empty;

use clap::CommandFactory;
Opt::command().debug_assert();
}

0 comments on commit 35eeba0

Please sign in to comment.