|
| None | __init__ (self, cabc.Sequence[str]|None param_decls=None, bool|str|None show_default=None, bool|str prompt=False, bool|str confirmation_prompt=False, bool prompt_required=True, bool hide_input=False, bool|None is_flag=None, t.Any flag_value=UNSET, bool multiple=False, bool count=False, bool allow_from_autoenv=True, types.ParamType|t.Any|None type=None, str|None help=None, bool hidden=False, bool show_choices=True, bool show_envvar=False, bool|str deprecated=False, **t.Any attrs) |
| |
| dict[str, t.Any] | to_info_dict (self) |
| |
| str | get_error_hint (self, Context ctx) |
| |
| None | add_to_parser (self, _OptionParser parser, Context ctx) |
| |
| tuple[str, str]|None | get_help_record (self, Context ctx) |
| |
|
types.OptionHelpExtra | get_help_extra (self, Context ctx) |
| |
| t.Any | prompt_for_value (self, Context ctx) |
| |
| str|None | resolve_envvar_value (self, Context ctx) |
| |
| t.Any | value_from_envvar (self, Context ctx) |
| |
| tuple[t.Any, ParameterSource] | consume_value (self, Context ctx, cabc.Mapping[str, Parameter] opts) |
| |
| t.Any | process_value (self, Context ctx, t.Any value) |
| |
|
str | __repr__ (self) |
| |
| str | human_readable_name (self) |
| |
|
str | make_metavar (self, Context ctx) |
| |
|
t.Any|None | get_default (self, Context ctx, t.Literal[True] call=True) |
| |
|
t.Any|t.Callable[[], t.Any]|None | get_default (self, Context ctx, bool call=...) |
| |
| t.Any|t.Callable[[], t.Any]|None | get_default (self, Context ctx, bool call=True) |
| |
| t.Any | type_cast_value (self, Context ctx, t.Any value) |
| |
| bool | value_is_missing (self, t.Any value) |
| |
| tuple[t.Any, list[str]] | handle_parse_result (self, Context ctx, cabc.Mapping[str, t.Any] opts, list[str] args) |
| |
|
list[str] | get_usage_pieces (self, Context ctx) |
| |
| list[CompletionItem] | shell_complete (self, Context ctx, str incomplete) |
| |
Options are usually optional values on the command line and
have some extra features that arguments don't have.
All other parameters are passed onwards to the parameter constructor.
:param show_default: Show the default value for this option in its
help text. Values are not shown by default, unless
:attr:`Context.show_default` is ``True``. If this value is a
string, it shows that string in parentheses instead of the
actual value. This is particularly useful for dynamic options.
For single option boolean flags, the default remains hidden if
its value is ``False``.
:param show_envvar: Controls if an environment variable should be
shown on the help page and error messages.
Normally, environment variables are not shown.
:param prompt: If set to ``True`` or a non empty string then the
user will be prompted for input. If set to ``True`` the prompt
will be the option name capitalized. A deprecated option cannot be
prompted.
:param confirmation_prompt: Prompt a second time to confirm the
value if it was prompted for. Can be set to a string instead of
``True`` to customize the message.
:param prompt_required: If set to ``False``, the user will be
prompted for input only when the option was specified as a flag
without a value.
:param hide_input: If this is ``True`` then the input on the prompt
will be hidden from the user. This is useful for password input.
:param is_flag: forces this option to act as a flag. The default is
auto detection.
:param flag_value: which value should be used for this flag if it's
enabled. This is set to a boolean automatically if
the option string contains a slash to mark two options.
:param multiple: if this is set to `True` then the argument is accepted
multiple times and recorded. This is similar to ``nargs``
in how it works but supports arbitrary number of
arguments.
:param count: this flag makes an option increment an integer.
:param allow_from_autoenv: if this is enabled then the value of this
parameter will be pulled from an environment
variable in case a prefix is defined on the
context.
:param help: the help string.
:param hidden: hide this option from help outputs.
:param attrs: Other command arguments described in :class:`Parameter`.
.. versionchanged:: 8.2
``envvar`` used with ``flag_value`` will always use the ``flag_value``,
previously it would use the value of the environment variable.
.. versionchanged:: 8.1
Help text indentation is cleaned here instead of only in the
``@option`` decorator.
.. versionchanged:: 8.1
The ``show_default`` parameter overrides
``Context.show_default``.
.. versionchanged:: 8.1
The default of a single option boolean flag is not shown if the
default value is ``False``.
.. versionchanged:: 8.0.1
``type`` is detected from ``flag_value`` if given.
| t.Any click.core.Option.value_from_envvar |
( |
|
self, |
|
|
Context |
ctx |
|
) |
| |
For :class:`Option`, this method processes the raw environment variable
string the same way as :func:`Parameter.value_from_envvar` does.
But in the case of non-boolean flags, the value is analyzed to determine if the
flag is activated or not, and returns a boolean of its activation, or the
:attr:`flag_value` if the latter is set.
This method also takes care of repeated options (i.e. options with
:attr:`multiple` set to ``True``).
:meta private:
Reimplemented from click.core.Parameter.