Skip to content

Commit 1823cef

Browse files
committed
fix(parser): Don't panic when subcommands conflict with groups
Mentioned in #6182
1 parent dcc2846 commit 1823cef

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clap_builder/src/parser/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ impl<'cmd> Parser<'cmd> {
483483
pos_sc_name.clone(),
484484
matcher
485485
.arg_ids()
486-
.map(|id| self.cmd.find(id).unwrap().to_string())
486+
// skip groups
487+
.filter_map(|id| self.cmd.find(id).map(|a| a.to_string()))
487488
.collect(),
488489
Usage::new(self.cmd).create_usage_with_title(&[]),
489490
));

tests/builder/conflicts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ fn args_negate_subcommands_two_levels() {
990990
}
991991

992992
#[test]
993-
#[should_panic]
994993
fn group_conrflicts_with_subcommands() {
995994
let c = Command::new("test")
996995
.args_conflicts_with_subcommands(true)

0 commit comments

Comments
 (0)