Clarification on how parameters are named
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Doug Harris · committed by Doug Harris · parent ea213fc · Browse files · 3 files·+21 added−12 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+21 added−12 removed
- other:+21 added−12 removed
Provenance
- Commit
1f77db1- Tree
1f0598a- Author
Doug Harris <dharris@gmail.com>- Committer
Doug Harris <dharris@gmail.com>- Parent
ea213fc
3 files changed+21 added−12 removed
modified:docs/documentation.rst+1 added
74 unmodified lines75 .. click:run::76 77 invoke(cli, args=['--help'])78 79+.. _doc-meta-variables:80 81 Meta Variables82 --------------83 80 unmodified linesmodified:docs/parameters.rst+18 added-10 removed
75 unmodified lines76 77 Parameter Names78 ---------------79 80-Parameters (both options and arguments) accept a number of positional81-arguments which are the parameter declarations. Each string with a82-single dash is added as short argument; each string starting with a double83-dash as long one. If a string is added without any dashes, it becomes the84-internal parameter name which is also used as variable name.80+Parameters (both options and arguments) accept a number of positional arguments81+which are passed to the command function as parameters. Each string with a82+single dash is added as a short argument; each string starting with a double83+dash as a long one.84 86-If a parameter is not given a name without dashes, a name is generated85+If a string is added without any dashes, it becomes the internal parameter name86+which is also used as variable name.87+88+If all names for a parameter contain dashes, the internal name is generated89 automatically by taking the longest argument and converting all dashes to88-underscores. For an option with ``('-f', '--foo-bar')``, the parameter89-name is `foo_bar`. For an option with ``('-x',)``, the parameter is `x`.90-For an option with ``('-f', '--filename', 'dest')``, the parameter is91-called `dest`.90+underscores.91 92+Examples:93+94+* For an option with ``('-f', '--foo-bar')``, the parameter name is `foo_bar`.95+* For an option with ``('-x',)``, the parameter is `x`.96+* For an option with ``('-f', '--filename', 'dest')``, the parameter name is `dest`.97+* For an arguments with ``(`foogle`)``, the parameter name is `foogle`. To98+ provide a different human readable name for use in help text, see the section99+ about :ref:`doc-meta-variables`.100+101 Implementing Custom Types102 -------------------------103 104 To implement a custom type, you need to subclass the :class:`ParamType`27 unmodified linesmodified:docs/quickstart.rst+2 added-2 removed
118 unmodified lines119 <https://github.com/pallets/click/tree/master/examples/termui>`_120 * ``imagepipe``: `Multi command chaining demo121 <https://github.com/pallets/click/tree/master/examples/imagepipe>`_122 123-Basic Concepts124---------------123+Basic Concepts - Creating a Command124+-----------------------------------125 126 Click is based on declaring commands through decorators. Internally, there127 is a non-decorator interface for advanced use cases, but it's discouraged128 for high-level usage.146 unmodified lines