class documentation

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. 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. :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. .. versionchanged:: 8.1.0 Help text indentation is cleaned here instead of only in the ``@option`` decorator. .. versionchanged:: 8.1.0 The ``show_default`` parameter overrides ``Context.show_default``. .. versionchanged:: 8.1.0 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.

Method __init__ Undocumented
Method add_to_parser Undocumented
Method consume_value Undocumented
Method get_default Get the default for the parameter. Tries :meth:`Context.lookup_default` first, then the local default.
Method get_help_record Undocumented
Method prompt_for_value This is an alternative flow that can be activated in the full value processing if a value does not exist. It will prompt the user until a valid value exists and then returns the processed value as result.
Method resolve_envvar_value Undocumented
Method to_info_dict Gather information that could be useful for a tool generating user-facing documentation.
Method value_from_envvar Undocumented
Class Variable param_type_name Undocumented
Instance Variable allow_from_autoenv Undocumented
Instance Variable confirmation_prompt Undocumented
Instance Variable count Undocumented
Instance Variable default Undocumented
Instance Variable flag_value Undocumented
Instance Variable help Undocumented
Instance Variable hidden Undocumented
Instance Variable hide_input Undocumented
Instance Variable is_bool_flag Undocumented
Instance Variable is_flag Undocumented
Instance Variable prompt Undocumented
Instance Variable prompt_required Undocumented
Instance Variable show_choices Undocumented
Instance Variable show_default Undocumented
Instance Variable show_envvar Undocumented
Instance Variable type Undocumented
Method _parse_decls Undocumented
Instance Variable _flag_needs_value Undocumented

Inherited from Parameter:

Method __repr__ Undocumented
Method get_error_hint Get a stringified version of the param for use in error messages to indicate which param caused the error.
Method get_usage_pieces Undocumented
Method handle_parse_result Undocumented
Method make_metavar Undocumented
Method process_value Undocumented
Method shell_complete Return a list of completions for the incomplete value. If a ``shell_complete`` function was given during init, it is used. Otherwise, the :attr:`type` :meth:`~click.types.ParamType.shell_complete` function is used.
Method type_cast_value Convert and validate a value against the option's :attr:`type`, :attr:`multiple`, and :attr:`nargs`.
Method value_is_missing Undocumented
Instance Variable callback Undocumented
Instance Variable envvar Undocumented
Instance Variable expose_value Undocumented
Instance Variable is_eager Undocumented
Instance Variable metavar Undocumented
Instance Variable multiple Undocumented
Instance Variable name Undocumented
Instance Variable nargs Undocumented
Instance Variable opts Undocumented
Instance Variable required Undocumented
Instance Variable secondary_opts Undocumented
Property human_readable_name Returns the human readable name of this parameter. This is the same as the name for options, but the metavar for arguments.
Instance Variable _custom_shell_complete Undocumented
def __init__(self, param_decls=None, show_default=None, prompt=False, confirmation_prompt=False, prompt_required=True, hide_input=False, is_flag=None, flag_value=None, multiple=False, count=False, allow_from_autoenv=True, type=None, help=None, hidden=False, show_choices=True, show_envvar=False, **attrs): (source)

Undocumented

Parameters
param_decls:t.Optional[t.Sequence[str]]Undocumented
show_default:t.Union[bool, str, None]Undocumented
prompt:t.Union[bool, str]Undocumented
confirmation_prompt:t.Union[bool, str]Undocumented
prompt_required:boolUndocumented
hide_input:boolUndocumented
is_flag:t.Optional[bool]Undocumented
flag_value:t.Optional[t.Any]Undocumented
multiple:boolUndocumented
count:boolUndocumented
allow_from_autoenv:boolUndocumented
type:t.Optional[t.Union[types.ParamType, t.Any]]Undocumented
help:t.Optional[str]Undocumented
hidden:boolUndocumented
show_choices:boolUndocumented
show_envvar:boolUndocumented
**attrs:t.AnyUndocumented
def add_to_parser(self, parser, ctx): (source)

Undocumented

Parameters
parser:OptionParserUndocumented
ctx:ContextUndocumented
def consume_value(self, ctx, opts): (source)

Undocumented

Parameters
ctx:ContextUndocumented
opts:t.Mapping[str, Parameter]Undocumented
Returns
t.Tuple[t.Any, ParameterSource]Undocumented
def get_default(self, ctx, call=True): (source)

Get the default for the parameter. Tries :meth:`Context.lookup_default` first, then the local default. :param ctx: Current context. :param call: If the default is a callable, call it. Disable to return the callable instead. .. versionchanged:: 8.0.2 Type casting is no longer performed when getting a default. .. versionchanged:: 8.0.1 Type casting can fail in resilient parsing mode. Invalid defaults will not prevent showing help text. .. versionchanged:: 8.0 Looks at ``ctx.default_map`` first. .. versionchanged:: 8.0 Added the ``call`` parameter.

Parameters
ctx:ContextUndocumented
call:boolUndocumented
Returns
t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]Undocumented
def get_help_record(self, ctx): (source)

Undocumented

Parameters
ctx:ContextUndocumented
Returns
t.Optional[t.Tuple[str, str]]Undocumented
def prompt_for_value(self, ctx): (source)

This is an alternative flow that can be activated in the full value processing if a value does not exist. It will prompt the user until a valid value exists and then returns the processed value as result.

Parameters
ctx:ContextUndocumented
Returns
t.AnyUndocumented
def resolve_envvar_value(self, ctx): (source)

Undocumented

Parameters
ctx:ContextUndocumented
Returns
t.Optional[str]Undocumented
def to_info_dict(self): (source)

Gather information that could be useful for a tool generating user-facing documentation. Use :meth:`click.Context.to_info_dict` to traverse the entire CLI structure. .. versionadded:: 8.0

Returns
t.Dict[str, t.Any]Undocumented
def value_from_envvar(self, ctx): (source)

Undocumented

Parameters
ctx:ContextUndocumented
Returns
t.Optional[t.Any]Undocumented
param_type_name: str = (source)

Undocumented

allow_from_autoenv = (source)

Undocumented

confirmation_prompt = (source)

Undocumented

count = (source)

Undocumented

default: int = (source)

Undocumented

flag_value: t.Any = (source)

Undocumented

help = (source)

Undocumented

hidden = (source)

Undocumented

hide_input = (source)

Undocumented

is_bool_flag = (source)

Undocumented

is_flag: bool = (source)

Undocumented

prompt = (source)

Undocumented

prompt_required = (source)

Undocumented

show_choices = (source)

Undocumented

show_default = (source)

Undocumented

show_envvar = (source)

Undocumented

type = (source)

Undocumented

def _parse_decls(self, decls, expose_value): (source)

Undocumented

Parameters
decls:t.Sequence[str]Undocumented
expose_value:boolUndocumented
Returns
t.Tuple[t.Optional[str], t.List[str], t.List[str]]Undocumented
_flag_needs_value = (source)

Undocumented