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
Add no_args_is_help to click.Command #1167
Conversation
The functionality for no_args_is_help, available on MultiCommands, can easily be added on Commands as well. The result is not much more code, and a more consistent interface between MultiCommands and Commands. It's also nice to be able to write a click command `foo` and then just hit `foo` for help, regardless of whether its a Group or Command. closes pallets#1156
db7e9bf
to
624a328
Compare
I just had a coworker ask me about this feature (unaware of this PR), so I guess that's a 👍 from somewhere for this feature. In #1156 I said I wasn't sure we needed this, but maybe I'm changing my tune on it. Seems easy for |
Looks good to me. Should there be a check that there is at least one required arg? Otherwise you wouldn't actually be able to run the command. Guess at that point you should have just not set |
624a328
to
02ba36f
Compare
Yeah, I think "just don't try to do that" is a reasonable stance. I noticed a small typo in my changelog entry, which I just amended. That's why there's a fresh commit. |
Hi, do developers need to wait for the 7.1 release to use this feature? Or is there a branch I can switch to in order to have access to this earlier? I'm using Thanks! |
@simonkeng, if you want to use this ahead of the 7.1 release, you could install from the 7.x branch directly or even from a specific commit on said branch. There are a few ways to install from GitHub with You might be better served (until 7.1 releases) by just printing the helptext yourself with
if you pass the context to your commands. If I needed this behavior in my own tools, I'd probably opt for explicitly printing help myself. |
The functionality for no_args_is_help, available on MultiCommands, can easily be added on Commands as well. The result is not much more code, and a more consistent interface between MultiCommands and Commands.
It's also nice to be able to write a click command
foo
and then just hitfoo
for help, regardless of whether its a Group or Command.closes #1156
Will add changelog edit in a moment, after this PR is assigned a number.