Skip to content
Myr

Cleanup typos.

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

authored by Edward G · committed by Edward G · parent a31c463 · Browse files · 1 file+8 added−14 removed
This commit

State

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

Diff stats

1 file+8 added−14 removed

  • other:+8 added−14 removed

1 file+8 added−14 removed

modified:docs/commands-and-groups.rst+8 added-14 removed
51 unmodified lines
52 invoke(hello, args=['--count', '2',])5354Basic Group Example55---------------------56A group wraps command(s). After being wrapped, the commands are nested under that group. You can see that on the help pages and in the execution. By default, invoking the group with no command shows the help page.56A group wraps one or more commands. After being wrapped, the commands are nested under that group. You can see that on the help pages and in the execution. By default, invoking the group with no command shows the help page.5758.. click:example::59 @click.group()60 def greeting():
24 unmodified lines
85-----------------86To have a name other than the decorated function name as the group name, pass it in as the first positional argument.8788.. click:example::89 @click.group('greet_someone')89 @click.group('greet-someone')90 def greeting():91 click.echo('Starting greeting ...')9293 @greeting.command('say-hello')
8 unmodified lines
102103Group Invocation Without Command104--------------------------------105106By default, a group is not invoked unless a subcommand is passed. In fact, not107providing a command automatically passes ``--help`` by default. This behavior108can be changed by passing ``invoke_without_command=True`` to a group. In that109case, the callback is always invoked instead of showing the help page. The110context object also includes information about whether or not the invocation111would go to a subcommand.106By default, if a group is passed without a command, the group is not invoked and a command automatically passes ``--help``. To change this, pass ``invoke_without_command=True`` to the group. The context object also includes information about whether or not the group invocation would go to a command nested under it.107108.. click:example::109110 @click.group(invoke_without_command=True)
16 unmodified lines
127128129Group Separation130--------------------------136Within a group, command :ref:`parameters` attached to a command belong only to that command.131Command :ref:`parameters` attached to a command belong only to that command.132133.. click:example::134 @click.group()135 def greeting():
22 unmodified lines
158This behavior is observable with the ``--help`` option. Suppose we have a group called ``tool`` containing a command called ``sub``.159160- ``tool --help`` returns the help for the whole program (listing subcommands).161- ``tool sub --help`` returns the help for the ``sub`` subcommand.167- But ``tool.py --help sub`` treats ``--help`` as an argument for the main program. Click then invokes the callback for ``--help``, which prints the help and aborts the program before click can process the subcommand.162- But ``tool --help sub`` treats ``--help`` as an argument for the main program. Click then invokes the callback for ``--help``, which prints the help and aborts the program before click can process the subcommand.163164Arbitrary Nesting165------------------171:class:`Commands <Command>` are attached to a :class:`Group`. Multiple groups can be attached to another group. Groups containing multiple groups can be attached to a group, and so on. To invoke a command nested under multiple groups, all the groups under which it is nested must added.166:class:`Commands <Command>` are attached to a :class:`Group`. Multiple groups can be attached to another group. Groups containing multiple groups can be attached to a group, and so on. To invoke a command nested under multiple groups, all the groups under which it is nested must be invoked.167168.. click:example::169170 @click.group()
18 unmodified lines
189 invoke(cli, args=['session', 'initdb'])190191Lazily Attaching Commands192--------------------------198Most examples so far have attached the commands and to a group immediately, but commands may be registered later. This could be used to split commands into multiple Python modules. Regardless of how they are attached, the commands are invoked identically.193Most examples so far have attached the commands to a group immediately, but commands may be registered later. This could be used to split commands into multiple Python modules. Regardless of how they are attached, the commands are invoked identically.194195.. click:example::196197 @click.group()198 def cli():199 pass200206 @click.command()201 @cli.command()202 def initdb():203 click.echo('Initialized the database')204205 @click.command()206 def dropdb():207 click.echo('Dropped the database')208214 cli.add_command(initdb)209 cli.add_command(dropdb)210211.. click:run::212
6 unmodified lines