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

Merged
merged 2 commits into from Nov 30, 2018

Conversation

Projects
None yet
2 participants
@sirosen
Contributor

sirosen commented Nov 10, 2018

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 #1156

Will add changelog edit in a moment, after this PR is assigned a number.

Add no_args_is_help to click.Command
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 #1156

@sirosen sirosen force-pushed the sirosen:no-args-help-command branch from db7e9bf to 624a328 Nov 10, 2018

@sirosen sirosen changed the base branch from master to 7.x Nov 10, 2018

@sirosen

This comment has been minimized.

Contributor

sirosen commented Nov 29, 2018

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 click to do, and confusing for people new to the framework.

@davidism

This comment has been minimized.

Member

davidism commented Nov 29, 2018

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 no_args_is_help though.

@sirosen sirosen force-pushed the sirosen:no-args-help-command branch from 624a328 to 02ba36f Nov 30, 2018

@sirosen

This comment has been minimized.

Contributor

sirosen commented Nov 30, 2018

Yeah, I think "just don't try to do that" is a reasonable stance.
I wouldn't check for a required arg, since someone might have a command which takes a bunch of options which determine its behavior. e.g. command --mode1 and command --mode2 are valid, but command on its own is not.

I noticed a small typo in my changelog entry, which I just amended. That's why there's a fresh commit.

@davidism davidism added this to the 7.1 milestone Nov 30, 2018

@davidism davidism merged commit 43eb54d into pallets:7.x Nov 30, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@sirosen sirosen deleted the sirosen:no-args-help-command branch Dec 1, 2018

@jcrotts jcrotts referenced this pull request Dec 7, 2018

Closed

Show all missing args #1175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment