Skip to content
Myr

Merge pull request #1645 from pallets/quickstart-add_command

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

show group.add_command in quickstart

authored by David Lord · committed by GitHub · parents 0d43812, a1555bf · Browse files · 1 file+24 added−0 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+24 added−0 removed

  • other:+24 added−0 removed

1 file+24 added−0 removed

modified:docs/quickstart.rst+24 added
224 unmodified lines
225226 if __name__ == '__main__':227 cli()228229230Registering Commands Later231--------------------------232233Instead of using the ``@group.command()`` decorator, commands can be234decorated with the plain ``@click.command()`` decorator and registered235with a group later with ``group.add_command()``. This could be used to236split commands into multiple Python modules.237238.. code-block:: python239240 @click.command()241 def greet():242 click.echo("Hello, World!")243244.. code-block:: python245246 @click.group()247 def group():248 pass249250 group.add_command(greet)251252253Adding Parameters254-----------------255256To add parameters, use the :func:`option` and :func:`argument` decorators:
43 unmodified lines