Skip to content
Myr

Merge pull request #1009 from dougharris/parameter-949

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

Clarification on how parameters are named

authored by Dan Sully · committed by GitHub · parents 692cb32, 1f77db1 · 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

3 files+21 added−12 removed

modified:docs/documentation.rst+1 added
74 unmodified lines
75.. click:run::7677 invoke(cli, args=['--help'])7879.. _doc-meta-variables:8081Meta Variables82--------------83
80 unmodified lines
modified:docs/parameters.rst+18 added-10 removed
75 unmodified lines
7677Parameter Names78---------------7980Parameters (both options and arguments) accept a number of positional81arguments which are the parameter declarations. Each string with a82single dash is added as short argument; each string starting with a double83dash as long one. If a string is added without any dashes, it becomes the84internal parameter name which is also used as variable name.80Parameters (both options and arguments) accept a number of positional arguments81which are passed to the command function as parameters. Each string with a82single dash is added as a short argument; each string starting with a double83dash as a long one.8486If a parameter is not given a name without dashes, a name is generated85If a string is added without any dashes, it becomes the internal parameter name86which is also used as variable name.8788If all names for a parameter contain dashes, the internal name is generated89automatically by taking the longest argument and converting all dashes to88underscores. For an option with ``('-f', '--foo-bar')``, the parameter89name is `foo_bar`. For an option with ``('-x',)``, the parameter is `x`.90For an option with ``('-f', '--filename', 'dest')``, the parameter is91called `dest`.90underscores.9192Examples:9394* 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`.100101Implementing Custom Types102-------------------------103104To implement a custom type, you need to subclass the :class:`ParamType`
27 unmodified lines
modified:docs/quickstart.rst+2 added-2 removed
118 unmodified lines
119 <https://github.com/pallets/click/tree/master/examples/termui>`_120* ``imagepipe``: `Multi command chaining demo121 <https://github.com/pallets/click/tree/master/examples/imagepipe>`_122123Basic Concepts124--------------123Basic Concepts - Creating a Command124-----------------------------------125126Click is based on declaring commands through decorators. Internally, there127is a non-decorator interface for advanced use cases, but it's discouraged128for high-level usage.
148 unmodified lines