Skip to content
Myr

Convert parameters file to md. (#2953)

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

authored by Rowlando13 · committed by GitHub · parents 3a917b9, 3aebc6e · Browse files · 3 files+57 added−59 removed
This commit

State

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

Diff stats

3 files+57 added−59 removed

  • other:+57 added−59 removed

3 files+57 added−59 removed

modified:docs/documentation.rst+2 added-1 removed
197 unmodified lines
198.. code-block:: python199200 cli(max_content_width=120)201202.. _doc-meta-variables:202203204Truncating Help Texts205---------------------206207Click gets :class:`Command` help text from the docstring. If you do not want to include part of the docstring, add the ``\f`` escape marker to have Click truncate the help text after the marker.
13 unmodified lines
221.. click:run::222223 invoke(cli, args=['--help'])224225.. _doc-meta-variables:226227Placeholder / Meta Variable228-----------------------------229
39 unmodified lines
added:docs/parameters.md+55 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')