Click: Display manually help

Created on 25 Jul 2016  路  6Comments  路  Source: pallets/click

Hello,

I'd like my command line do nothing except display cli help if no parameter is passed.
How to force to display help ?

Kind regards

Most helpful comment

That isn't a satisfactory solution for us because we have different behavior for noargs with stdin and noargs without stdin. There are also other scenarios you can obviously imagine where somebody would want to manually display the help text.

We need this feature surfaced and documented - can you please reopen this ticket?

All 6 comments

I'm going CRAZY trying to figure this out right now, this absolutely needs to be a feature, or if it already is, it absolutely needs to be surfaced in the documentation. So annoying.

@femtotrader Use no_args_is_help=True on the command decorator (@click.command(no_args_is_help=True)). This is enabled for groups by default.

Sorry, actually no_args_is_help is not available for Command, but implemented in #502.

That isn't a satisfactory solution for us because we have different behavior for noargs with stdin and noargs without stdin. There are also other scenarios you can obviously imagine where somebody would want to manually display the help text.

We need this feature surfaced and documented - can you please reopen this ticket?

In that case you can also use ctx.get_help, which is internally used as well by help_option. It _is_ documented, but arguably not very well. Patches are always welcome though!

Also I'd reconsider if printing out the entire help on incorrect usage is obscuring the previously printed error message (which is why click generally doesn't give the user that much choice in UX design).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ror6ax picture ror6ax  路  4Comments

joveice picture joveice  路  3Comments

mitsuhiko picture mitsuhiko  路  3Comments

rbonthond picture rbonthond  路  4Comments

inhumantsar picture inhumantsar  路  3Comments