Skip to content
Myr

Convert parameters file to md.

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 3a917b9 · Browse files · 2 files+56 added−58 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+56 added−58 removed

  • other:+56 added−58 removed

2 files+56 added−58 removed

added:docs/parameters.md+56 added
deleted:docs/parameters.rst-58 removed
1.. _parameters:23Parameters4==========56.. currentmodule:: click78Click supports only two principle types of parameters for scripts (by design): options and arguments.910Options11----------------1213* Are optional.14* Recommended to use for everything except subcommands, urls, or files.15* Can take a fixed number of arguments. The default is 1. They may be specified multiple times using :ref:`multiple-options`.16* Are fully documented by the help page.17* Have automatic prompting for missing input.18* Can act as flags (boolean or otherwise).19* Can be pulled from environment variables.2021Arguments22----------------2324* Are optional with in reason, but not entirely so.25* Recommended to use for subcommands, urls, or files.26* Can take an arbitrary number of arguments.27* Are not fully documented by the help page since they may be too specific to be automatically documented. For more see :ref:`documenting-arguments`.28* Can be pulled from environment variables but only explicitly named ones. For more see :ref:`environment-variables`.2930On 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.3132.. _parameter_names:3334Parameter Names35---------------3637Parameters (options and arguments) have a name that will be used as38the Python argument name when calling the decorated function with39values.4041.. click:example::4243 @click.command()44 @click.argument('filename')45 @click.option('-t', '--times', type=int)46 def multi_echo(filename, times):47 """Print value filename multiple times."""48 for x in range(times):49 click.echo(filename)5051In 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`.52The option's names are ``-t`` and ``--times``. More names are available for options and are covered in :ref:`options`.5354And what it looks like when run:5556.. click:run::5758 invoke(multi_echo, ['--times=3', 'index.txt'], prog_name='multi_echo')