args_conflicts_with_subcommands
is not overriding subcommand_required = true
#5358
Labels
A-parsing
Area: Parser's logic and needs it changed somehow.
E-easy
Call for participation: Experience needed to fix: Easy / not much
M-breaking-change
Meta: Implementing or merging this will introduce a breaking change.
Discussed in #5353
Originally posted by fooblinator February 15, 2024
I have a flag ("--about") at the "top level", meaning as a child argument of the program's command. It's a bool so is optional. I don't need it to be required. I also have a subcommand at the same level, which points to an enum of subcommands, whose variants point to other enums (nested subcommands).
As a config option, I have "args_conflicts_with_subcommands" set to true. Also, I have "arg_required_else_help" set to false, so I can see the generated error, when I fail to provide a command name. The error and usage makes good sense, and when not providing a subcommand, this message makes good suggestions about what to try:
The above happens when my subcommand is configured to be required (through not configuring it as an Option<T>).
Question is: is there a way to have the functionality where:
Here's some code I'm using:
In summary, when I make my top-level commands required ("commands: CliCmds"), I can't use the "--about" top-level flag. But when I make those subcommands optional ("command: Option<CliCmds>"), then I can use the flag, but the helpful error doesn't display (when neither "--about" nor a subcommand is passed).
The text was updated successfully, but these errors were encountered: