Skip to content

Commit

Permalink
fix(parser): Don't panic with conflicts and groups
Browse files Browse the repository at this point in the history
With #5298, I had overlooked that `matcher.arg_ids()` includes
`ArgGroup`s.  I had assumed I could always find a present `id` among
`Arg`s and `unwrap`ed.

I skipped a test for this because the use case is a bit strange that the
long term value for the test would likely be low.
If/when we add derive support for `args_conflicts_with_subcommands`, it
will then cover this case.

Fixes #5304
  • Loading branch information
epage committed Jan 15, 2024
1 parent cbc9c9d commit 50c59f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clap_builder/src/parser/parser.rs
Expand Up @@ -514,7 +514,7 @@ impl<'cmd> Parser<'cmd> {
arg_os.display().to_string(),
matcher
.arg_ids()
.map(|id| self.cmd.find(id).unwrap().to_string())
.filter_map(|id| self.cmd.find(id).map(|a| a.to_string()))
.collect(),
Usage::new(self.cmd).create_usage_with_title(&[]),
);
Expand Down

0 comments on commit 50c59f6

Please sign in to comment.