Skip to content
Myr

replace references to 'callback' and 'parameter declarations'

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

authored by Brian Hall · committed by Brian Hall · parent 5590ef4 · Browse files · 1 file+8 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

1 file+8 added−6 removed

  • other:+8 added−6 removed

1 file+8 added−6 removed

modified:docs/options.md+8 added-6 removed
55 unmodified lines
56```5758More formally, Click will try to infer the callback argument name as follows:59601. If a parameter declaration is a valid [`Python identifier`](https://docs.python.org/3/reference/lexical_analysis.html#identifiers), it is chosen.612. If multiple parameter declarations are prefixed with `--`, the one that was declared first is chosen.623. Otherwise, the first parameter declaration prefixed with `-` is chosen.601. If a positional argument is a valid [Python identifier], it is chosen.612. If multiple positional arguments are prefixed with `--`, the one that was declared first is chosen.623. Otherwise, the first positional argument prefixed with `-` is chosen.6364To get the callback argument name, the chosen parameter declaration is converted to lower case, a leading `-` or `--` is removed if found, and any remaining `-` characters are replaced with `_`.64[Python identifier]: https://docs.python.org/3/reference/lexical_analysis.html#identifiers6566To get the argument name, the chosen positional argument is converted to lower case, a leading `-` or `--` is removed if found, and any remaining `-` characters are replaced with `_`.6768```{eval-rst}69.. list-table:: Examples70 :widths: 15 1571 :header-rows: 17271 * - Parameter Declarations73 * - Decorator Arguments74 - Inferred Argument Name75 * - ``"-f", "--foo-bar"``76 - foo_bar77 * - ``"-x"``
11 unmodified lines
89```9091## Basic Example9291A simple {class}`click.Option` takes one argument. By default, it's assumed that the corresponding callback argument is not required and the expected type is `str`. If the callback takes a positional argument but the option is not passed with the command, then `None` is passed to the callback.93A simple {class}`click.Option` takes one option name. By default, it's assumed that the decorated function argument is not required and the expected type is `str`. If the decorated function takes a positional argument but the option is not passed with the command, then `None` is passed.9495```{eval-rst}96.. click:example::97
405 unmodified lines