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 |
Undocumented |
Method | consume |
Undocumented |
Method | get |
Get the default for the parameter. Tries :meth:`Context.lookup_default` first, then the local default. |
Method | get |
Undocumented |
Method | prompt |
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 |
Undocumented |
Method | to |
Gather information that could be useful for a tool generating user-facing documentation. |
Method | value |
Undocumented |
Class Variable | param |
Undocumented |
Instance Variable | allow |
Undocumented |
Instance Variable | confirmation |
Undocumented |
Instance Variable | count |
Undocumented |
Instance Variable | default |
Undocumented |
Instance Variable | flag |
Undocumented |
Instance Variable | help |
Undocumented |
Instance Variable | hidden |
Undocumented |
Instance Variable | hide |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | prompt |
Undocumented |
Instance Variable | prompt |
Undocumented |
Instance Variable | show |
Undocumented |
Instance Variable | show |
Undocumented |
Instance Variable | show |
Undocumented |
Instance Variable | type |
Undocumented |
Method | _parse |
Undocumented |
Instance Variable | _flag |
Undocumented |
Inherited from Parameter
:
Method | __repr__ |
Undocumented |
Method | get |
Get a stringified version of the param for use in error messages to indicate which param caused the error. |
Method | get |
Undocumented |
Method | handle |
Undocumented |
Method | make |
Undocumented |
Method | process |
Undocumented |
Method | shell |
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 |
Convert and validate a value against the option's :attr:`type`, :attr:`multiple`, and :attr:`nargs`. |
Method | value |
Undocumented |
Instance Variable | callback |
Undocumented |
Instance Variable | envvar |
Undocumented |
Instance Variable | expose |
Undocumented |
Instance Variable | is |
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 |
Undocumented |
Property | human |
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 |
Undocumented |
click.core.Parameter.__init__
Undocumented
Parameters | |
paramt.Optional[ | Undocumented |
showt.Union[ | Undocumented |
prompt:t.Union[ | Undocumented |
confirmationt.Union[ | Undocumented |
promptbool | Undocumented |
hidebool | Undocumented |
ist.Optional[ | Undocumented |
flagt.Optional[ | Undocumented |
multiple:bool | Undocumented |
count:bool | Undocumented |
allowbool | Undocumented |
type:t.Optional[ | Undocumented |
help:t.Optional[ | Undocumented |
hidden:bool | Undocumented |
showbool | Undocumented |
showbool | Undocumented |
**attrs:t.Any | Undocumented |
click.core.Parameter.add_to_parser
Undocumented
Parameters | |
parser:OptionParser | Undocumented |
ctx:Context | Undocumented |
click.core.Parameter.get_default
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:Context | Undocumented |
call:bool | Undocumented |
Returns | |
t.Optional[ | Undocumented |
click.core.Parameter.get_help_record
Undocumented
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.Optional[ | Undocumented |
click.core.Parameter.value_from_envvar
Undocumented
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.Optional[ | Undocumented |
click.core.Parameter._parse_decls
Undocumented
Parameters | |
decls:t.Sequence[ | Undocumented |
exposebool | Undocumented |
Returns | |
t.Tuple[ | Undocumented |