-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only print help for subsubcommand when global settings subcommandneededelsehelp #2513
Comments
Is the bug here that we are requiring a subcommand at a level that has no subcommands and the proposed fix would be to ignore clap is doing exactly what it was told. I'm a bit cautious of it trying out out guess the user. Personally, I would only recommend using |
It seems that I'm not the only one who expected clap to behave otherwise, so my 2cents. The documentation says:
While technically clap behaves exactly as it was told, IMO it's still a bit counter-intuitive. Most of the time if I have the following command structure:
I want exactly the same behavior for all subcommands: if it has subcommands but no further arguments, exit with help. This makes it easier for people who in a hurry just type |
In #2717 we are exploring removing The lack of a
Something not covered in this issue that was in my original reply to #3270 before I realized it was a dupe is why I wasn't going to layer Now, decoupling the two concepts somehow could open us up to one being global while the other isn't. We'd just need to come up with a clear name / policy for this new setting (we already have btw I'd be curious if you have any thoughts on #1334 since you have such a large subcommand hierarchy. I'm assuming you are likely to run into cases like |
Hmm... I see. Yeah, in the presence of optional subcommands it does gets in the way.
Sounds good!
Well #1334 looks good. I would love to see some knobs to be able to do this:
|
For #1334, the way my proposal would work is $ git --help # #1334 is not enabled
[lists subcommands as if #1334 didn't exist]
$ git stash --help # #1334 is enabled
[shows help for all stash subcommands like push, pop, etc]
$ git stash pop --help # no subcommands
[shows pop's help as if #1334 didn't exist] Is that the same thing you were showing? The idea is that we'd only nest what the user opts into and adding additional subcommands would filter down the nesting to give a more specific view. |
Yeah! |
@heroin-moose I think I'm leaning towards this issue staying as is to make any decision on it easier to discover. If you'd like to see SubcommandRequiredElseHelp split up, could you create a separate issue? |
Sure, I'll reference this one for the discussion and give a short summary. Perhaps I can make a PR (not promising anything :)). |
I wonder why we have |
I've gone ahead and created #3280. As stated earlier, I'm leaning towards keeping SubcommandRequiredElseHelp doing literally what the user asked and looking to reject this issue. If there are thoughts on concerns about that, let us know! |
Please complete the following tasks
Rust Version
rustc 1.52.1 (9bc8c42bb 2021-05-09)
Clap Version
2.33.3
Minimal reproducible code
main.rs
cli.yml
Steps to reproduce the bug with the above code
$ cargo r -- a b
Actual Behaviour
Expected Behaviour
Additional Context
No response
Debug Output
The text was updated successfully, but these errors were encountered: