Any way to force a help subcommand to generate? #6226
Unanswered
twilight-flower
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
Instead of having the user to force-enable |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Consider a basic parser like this one:
This will automatically generate a
helpsubcommand for the root-level parser, because the root-level parser has a defined non-helpsubcommand. If you runcargo run -- helpon this source code, this will be a valid help-menu-invocation. If you want to go out of your way to prevent that from happening, you can add#[command(disable_help_subcommand = true)]above theExampleParserdefinition to prevent it; but, otherwise, no manual action is required.However, the same doesn't apply to the subcommands themselves. If you run
cargo run -- one help, it will fail with an 'unrecognized argument' error and tell you to try again with--help.This produces an awkward-and-inconsistent interface! It means that you can sometimes open the help menu via subcommand, but other times only via flag, and therefore means that trying to do so via subcommand is risky and suboptimal-to-try-if-you-don't-already-know-it'll-work.
Thus, I'm wondering if there's any option I've missed to do the inverse of
disable_help_subcommand: to force the help subcommand to generate even absent any other subcommands—for theoneandtwosubcommands, in this example-case—and thus ensure that the help interface is consistent throughout the parser's subcommand-tree.Beta Was this translation helpful? Give feedback.
All reactions