parameters.rst
This file
Path
docs/parameters.rst
56 lines · 2.1 KiB
Last changed by
Rewrite first half of options docs (#2825)Rowlando13before adoption82089af
History of this fileTake it
The walk stopped after 200 commits: lines older than f51584c point at it.
Merge pull request #1876 from pallets/pre-commit-ci-scheduleDavid Lordbefore adoptionf51584c
lines 1–5why, one step back1Parameters2==========34.. currentmodule:: click5Rewrite first half of options docs (#2825)Rowlando13before adoption82089af
line 6why, one step back6Click supports only two principle types of parameters for scripts (by design): options and arguments.Merge pull request #1876 from pallets/pre-commit-ci-scheduleDavid Lordbefore adoptionf51584c
line 7why, one step back7Merge stable into main (#2799)Rowlando13before adoptiond791537
lines 8–9why, one step back8Options9----------------Merge pull request #1876 from pallets/pre-commit-ci-scheduleDavid Lordbefore adoptionf51584c
line 10why, one step back10Merge stable into main (#2799)Rowlando13before adoptiond791537
lines 11–17why, one step back11* Are optional.12* Recommended to use for everything except subcommands, urls, or files.13* Can take a fixed number of arguments. The default is 1. They may be specified multiple times using :ref:`multiple-options`.14* Are fully documented by the help page.15* Have automatic prompting for missing input.16* Can act as flags (boolean or otherwise).17* Can be pulled from environment variables.Merge pull request #1876 from pallets/pre-commit-ci-scheduleDavid Lordbefore adoptionf51584c
line 18why, one step back18Merge stable into main (#2799)Rowlando13before adoptiond791537
lines 19–20why, one step back19Arguments20----------------Merge pull request #1876 from pallets/pre-commit-ci-scheduleDavid Lordbefore adoptionf51584c
line 21why, one step back21Merge stable into main (#2799)Rowlando13before adoptiond791537
lines 22–26why, one step back22* Are optional with in reason, but not entirely so.23* Recommended to use for subcommands, urls, or files.24* Can take an arbitrary number of arguments.25* Are not fully documented by the help page since they may be too specific to be automatically documented. For more see :ref:`documenting-arguments`.26* Can be pulled from environment variables but only explicitly named ones. For more see :ref:`environment-variables`.Merge pull request #1876 from pallets/pre-commit-ci-scheduleDavid Lordbefore adoptionf51584c
line 27why, one step back27Rewrite first half of options docs (#2825)Rowlando13before adoption82089af
lines 28–29why, one step back28On each principle type you can specify :ref:`parameter-types`. Specifying these types helps Click add details to your help pages and help with the handling of those types.29Merge stable into main (#2799)Rowlando13before adoptiond791537
line 30why, one step back30.. _parameter_names:Merge pull request #1876 from pallets/pre-commit-ci-scheduleDavid Lordbefore adoptionf51584c
line 31why, one step back31Merge stable into main (#2799)Rowlando13before adoptiond791537
lines 32–56why, one step back32Parameter Names33---------------3435Parameters (options and arguments) have a name that will be used as36the Python argument name when calling the decorated function with37values.3839.. click:example::4041 @click.command()42 @click.argument('filename')43 @click.option('-t', '--times', type=int)44 def multi_echo(filename, times):45 """Print value filename multiple times."""46 for x in range(times):47 click.echo(filename)4849In the above example the argument's name is ``filename``. The name must match the python arg name. To provide a different name for use in help text, see :ref:`doc-meta-variables`.50The option's names are ``-t`` and ``--times``. More names are available for options and are covered in :ref:`options`.5152And what it looks like when run:5354.. click:run::5556 invoke(multi_echo, ['--times=3', 'index.txt'], prog_name='multi_echo')