Skip to content
Myr

Fix typo. Add no_args_is help example.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Edward Girling · committed by Edward Girling · parent ad430d0 · Browse files · 2 files+21 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+21 added−8 removed

  • other:+21 added−8 removed

2 files+21 added−8 removed

modified:docs/command-line-reference.md+1 added-2 removed
modified:docs/exceptions.rst+20 added-6 removed
82 unmodified lines
8384Help Pages and Exit Codes85--------------------------8687Triggering the a help page intentionally (by passing in ``--help``) returns exit code 0. If a help page is display due to incorrect user provided input, the program returns exit code 2. See :ref:`exit-codes` for more on exit codes.87Triggering the a help page intentionally (by passing in ``--help``) returns exit code 0. If a help page is displayed due to incorrect user provided input, the program returns exit code 2. See :ref:`exit-codes` for more general information.8889For clarity, here is an example.9091.. click:example::9292 @click.group()93 @click.group('printer_group')94 def printer_group():95 pass9697 @printer_group.command('printer')
1 unmodified line
99 def printer(this):100 if this:101 click.echo(this)102103.. click:run::104 invoke(printer_group, args=['--help'])105106The above invocation returns exit code 0.107108.. click:run::109 invoke(printer_group, args=[])110106The above invocation returns exit code 2 since the user invoked the command incorrect. However, since this is such a common error when first using a command, Click invokes the help page for the user.111The above invocation returns exit code 2 since the user invoked the command incorrectly. However, since this is such a common error when first using a command, Click invokes the help page for the user. To see that `printer-group` is an invalid invocation, turn `no_args_is_help` off.112113.. click:example::114109.. click:run::110 invoke(printer_group, args=['--help'])115 @click.group('printer_group', no_args_is_help=False)116 def printer_group():117 pass118112The above invocation returns exit code 0.119 @printer_group.command('printer')120 @click.option('--this')121 def printer(this):122 if this:123 click.echo(this)124125.. click:run::126 invoke(printer_group, args=[])