Undocumented
Function | argument |
Attaches an argument to the command. All positional arguments are passed as parameter declarations to :class:`Argument`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Argument` instance manually and attaching it to the :attr:`Command... |
Function | command |
Creates a new :class:`Command` and uses the decorated function as callback. This will also automatically attach all decorated :func:`option`\s and :func:`argument`\s as parameters to the command. |
Function | confirmation |
Add a ``--yes`` option which shows a prompt before continuing if not passed. If the prompt is declined, the program will exit. |
Function | group |
Creates a new :class:`Group` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Group`. |
Function | help |
Add a ``--help`` option which immediately prints the help page and exits the program. |
Function | make |
Given an object type this creates a decorator that will work similar to :func:`pass_obj` but instead of passing the object of the current context, it will find the innermost context of type :func:`object_type`. |
Function | option |
Attaches an option to the command. All positional arguments are passed as parameter declarations to :class:`Option`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Option` instance manually and attaching it to the :attr:`Command... |
Function | pass |
Marks a callback as wanting to receive the current context object as first argument. |
Function | pass |
Create a decorator that passes a key from :attr:`click.Context.meta` as the first argument to the decorated function. |
Function | pass |
Similar to :func:`pass_context`, but only pass the object on the context onwards (:attr:`Context.obj`). This is useful if that object represents the state of a nested system. |
Function | password |
Add a ``--password`` option which prompts for a password, hiding input and asking to enter the value again for confirmation. |
Function | version |
Add a ``--version`` option which immediately prints the version number and exits the program. |
Constant | F |
Undocumented |
Constant | FC |
Undocumented |
Variable |
|
Undocumented |
Function | _param |
Undocumented |
Attaches an argument to the command. All positional arguments are passed as parameter declarations to :class:`Argument`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Argument` instance manually and attaching it to the :attr:`Command.params` list. :param cls: the argument class to instantiate. This defaults to :class:`Argument`.
Parameters | |
*paramstr | Undocumented |
**attrs:t.Any | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Creates a new :class:`Command` and uses the decorated function as callback. This will also automatically attach all decorated :func:`option`\s and :func:`argument`\s as parameters to the command. The name of the command defaults to the name of the function with underscores replaced by dashes. If you want to change that, you can pass the intended name as the first argument. All keyword arguments are forwarded to the underlying command class. For the ``params`` argument, any decorated params are appended to the end of the list. Once decorated the function turns into a :class:`Command` instance that can be invoked as a command line utility or be attached to a command :class:`Group`. :param name: the name of the command. This defaults to the function name with underscores replaced by dashes. :param cls: the command class to instantiate. This defaults to :class:`Command`. .. versionchanged:: 8.1 This decorator can be applied without parentheses. .. versionchanged:: 8.1 The ``params`` argument can be used. Decorated params are appended to the end of the list.
Parameters | |
name:t.Union[ | Undocumented |
cls:t.Optional[ | Undocumented |
**attrs:t.Any | Undocumented |
Returns | |
t.Union[ | Undocumented |
Add a ``--yes`` option which shows a prompt before continuing if not passed. If the prompt is declined, the program will exit. :param param_decls: One or more option names. Defaults to the single value ``"--yes"``. :param kwargs: Extra arguments are passed to :func:`option`.
Parameters | |
*paramstr | Undocumented |
**kwargs:t.Any | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Creates a new :class:`Group` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Group`. .. versionchanged:: 8.1 This decorator can be applied without parentheses.
Parameters | |
name:t.Union[ | Undocumented |
**attrs:t.Any | Undocumented |
Returns | |
t.Union[ | Undocumented |
Add a ``--help`` option which immediately prints the help page and exits the program. This is usually unnecessary, as the ``--help`` option is added to each command automatically unless ``add_help_option=False`` is passed. :param param_decls: One or more option names. Defaults to the single value ``"--help"``. :param kwargs: Extra arguments are passed to :func:`option`.
Parameters | |
*paramstr | Undocumented |
**kwargs:t.Any | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Given an object type this creates a decorator that will work similar to :func:`pass_obj` but instead of passing the object of the current context, it will find the innermost context of type :func:`object_type`. This generates a decorator that works roughly like this:: from functools import update_wrapper def decorator(f): @pass_context def new_func(ctx, *args, **kwargs): obj = ctx.find_object(object_type) return ctx.invoke(f, obj, *args, **kwargs) return update_wrapper(new_func, f) return decorator :param object_type: the type of the object to pass. :param ensure: if set to `True`, a new object will be created and remembered on the context if it's not there yet.
Parameters | |
objectt.Type | Undocumented |
ensure:bool | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Attaches an option to the command. All positional arguments are passed as parameter declarations to :class:`Option`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Option` instance manually and attaching it to the :attr:`Command.params` list. :param cls: the option class to instantiate. This defaults to :class:`Option`.
Parameters | |
*paramstr | Undocumented |
**attrs:t.Any | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Create a decorator that passes a key from :attr:`click.Context.meta` as the first argument to the decorated function. :param key: Key in ``Context.meta`` to pass. :param doc_description: Description of the object being passed, inserted into the decorator's docstring. Defaults to "the 'key' key from Context.meta". .. versionadded:: 8.0
Parameters | |
key:str | Undocumented |
doct.Optional[ | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Add a ``--password`` option which prompts for a password, hiding input and asking to enter the value again for confirmation. :param param_decls: One or more option names. Defaults to the single value ``"--password"``. :param kwargs: Extra arguments are passed to :func:`option`.
Parameters | |
*paramstr | Undocumented |
**kwargs:t.Any | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Add a ``--version`` option which immediately prints the version number and exits the program. If ``version`` is not provided, Click will try to detect it using :func:`importlib.metadata.version` to get the version for the ``package_name``. On Python < 3.8, the ``importlib_metadata`` backport must be installed. If ``package_name`` is not provided, Click will try to detect it by inspecting the stack frames. This will be used to detect the version, so it must match the name of the installed package. :param version: The version number to show. If not provided, Click will try to detect it. :param param_decls: One or more option names. Defaults to the single value ``"--version"``. :param package_name: The package name to detect the version from. If not provided, Click will try to detect it. :param prog_name: The name of the CLI to show in the message. If not provided, it will be detected from the command. :param message: The message to show. The values ``%(prog)s``, ``%(package)s``, and ``%(version)s`` are available. Defaults to ``"%(prog)s, version %(version)s"``. :param kwargs: Extra arguments are passed to :func:`option`. :raise RuntimeError: ``version`` could not be detected. .. versionchanged:: 8.0 Add the ``package_name`` parameter, and the ``%(package)s`` value for messages. .. versionchanged:: 8.0 Use :mod:`importlib.metadata` instead of ``pkg_resources``. The version is detected based on the package name, not the entry point name. The Python package name must match the installed package name, or be passed with ``package_name=``.
Parameters | |
version:t.Optional[ | Undocumented |
*paramstr | Undocumented |
packaget.Optional[ | Undocumented |
progt.Optional[ | Undocumented |
message:t.Optional[ | Undocumented |
**kwargs:t.Any | Undocumented |
Returns | |
t.Callable[ | Undocumented |