MCPcopy
hub / github.com/pallets/click / Option

Class Option

src/click/core.py:2791–3528  ·  view source on GitHub ↗

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 sho

Source from the content-addressed store, hash-verified

2789
2790
2791class Option(Parameter):
2792 """Options are usually optional values on the command line and
2793 have some extra features that arguments don't have.
2794
2795 All other parameters are passed onwards to the parameter constructor.
2796
2797 :param show_default: Show the default value for this option in its
2798 help text. Values are not shown by default, unless
2799 :attr:`Context.show_default` is ``True``. If this value is a
2800 string, it shows that string in parentheses instead of the
2801 actual value. This is particularly useful for dynamic options.
2802 For single option boolean flags, the default remains hidden if
2803 its value is ``False``.
2804 :param show_envvar: Controls if an environment variable should be
2805 shown on the help page and error messages.
2806 Normally, environment variables are not shown.
2807 :param prompt: If set to ``True`` or a non empty string then the
2808 user will be prompted for input. If set to ``True`` the prompt
2809 will be the option name capitalized. A deprecated option cannot be
2810 prompted.
2811 :param confirmation_prompt: Prompt a second time to confirm the
2812 value if it was prompted for. Can be set to a string instead of
2813 ``True`` to customize the message.
2814 :param prompt_required: If set to ``False``, the user will be
2815 prompted for input only when the option was specified as a flag
2816 without a value.
2817 :param hide_input: If this is ``True`` then the input on the prompt
2818 will be hidden from the user. This is useful for password input.
2819 :param is_flag: forces this option to act as a flag. The default is
2820 auto detection.
2821 :param flag_value: which value should be used for this flag if it's
2822 enabled. This is set to a boolean automatically if
2823 the option string contains a slash to mark two options.
2824 :param multiple: if this is set to `True` then the argument is accepted
2825 multiple times and recorded. This is similar to ``nargs``
2826 in how it works but supports arbitrary number of
2827 arguments.
2828 :param count: this flag makes an option increment an integer.
2829 :param allow_from_autoenv: if this is enabled then the value of this
2830 parameter will be pulled from an environment
2831 variable in case a prefix is defined on the
2832 context.
2833 :param help: the help string.
2834 :param hidden: hide this option from help outputs.
2835 :param attrs: Other command arguments described in :class:`Parameter`.
2836
2837 .. versionchanged:: 8.4.0
2838 Non-basic ``flag_value`` types (not ``str``, ``int``, ``float``, or
2839 ``bool``) are passed through unchanged instead of being stringified.
2840 Previously, ``type=click.UNPROCESSED`` was required to preserve them.
2841
2842 .. versionchanged:: 8.2
2843 ``envvar`` used with ``flag_value`` will always use the ``flag_value``,
2844 previously it would use the value of the environment variable.
2845
2846 .. versionchanged:: 8.1
2847 Help text indentation is cleaned here instead of only in the
2848 ``@option`` decorator.

Callers 15

test_flag_auto_detectionFunction · 0.90
test_commandFunction · 0.90
test_groupFunction · 0.90
test_nested_groupFunction · 0.90
test_chainedFunction · 0.90
test_type_choiceFunction · 0.90
test_option_countFunction · 0.90
test_option_optionalFunction · 0.90
test_path_typesFunction · 0.90

Calls

no outgoing calls

Tested by 15

test_flag_auto_detectionFunction · 0.72
test_commandFunction · 0.72
test_groupFunction · 0.72
test_nested_groupFunction · 0.72
test_chainedFunction · 0.72
test_type_choiceFunction · 0.72
test_option_countFunction · 0.72
test_option_optionalFunction · 0.72
test_path_typesFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…