Skip to content
Myr

correct docs about parameter name selection

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

authored by AlbertUlysses · committed by David Lord · parent 433708e · Browse files · 2 files+15 added−6 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+15 added−6 removed

  • other:+15 added−6 removed

2 files+15 added−6 removed

modified:docs/options.rst+2 added-1 removed
12 unmodified lines
13Name Your Options14-----------------1516The naming rules can be found in :ref:`parameter_names`. In short, you17can refer the option **implicitly** by the longest dash-prefixed argument:17can refer the option **implicitly** by the dash-prefixed hierarchy. 18Where two dashes comes before a single dash:1920.. click:example::2122 @click.command()
807 unmodified lines
modified:docs/parameters.rst+13 added-5 removed
89 unmodified lines
9091If a string is added without any dashes, it becomes the internal parameter name92which is also used as variable name.9394If all names for a parameter contain dashes, the internal name is generated95automatically by taking the longest argument and converting all dashes to96underscores.94If a string contains a single dash and a double dash, the double dash95becomes the internal parameter name.9697If there are multiple strings that contain a single dash, the first string98becomes the internal name. The same is true if all arguments begin with 99double dashes.100101All dashes after the beginning first two dashes convert to underscores.102103The internal name is converted to lowercase.104105Examples:106107* For an option with ``('-f', '--foo-bar')``, the parameter name is `foo_bar`.103* For an option with ``('-x',)``, the parameter is `x`.108* For an option with ``('-x',)``, the parameter name is `x`.109* For an option with ``('-f', '--filename', 'dest')``, the parameter name is `dest`.105* For an option with ``('--CamelCaseOption',)``, the parameter is `camelcaseoption`.110* For an option with ``('--CamelCaseOption',)``, the parameter name is `camelcaseoption`.111* For an option with ``('-f', '-foo-bar')``, the parameter name is `f`.112* For an option with ``('--f', '--foo-bar')``, the parameter name is `f`.113* For an option with ``('---f')``, the parameter name is `_f`.114* For an arguments with ``(`foogle`)``, the parameter name is `foogle`. To115 provide a different human readable name for use in help text, see the section116 about :ref:`doc-meta-variables`.117
41 unmodified lines