module documentation

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_option 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_option Add a ``--help`` option which immediately prints the help page and exits the program.
Function make_pass_decorator 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_context Marks a callback as wanting to receive the current context object as first argument.
Function pass_meta_key Create a decorator that passes a key from :attr:`click.Context.meta` as the first argument to the decorated function.
Function pass_obj 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_option Add a ``--password`` option which prompts for a password, hiding input and asking to enter the value again for confirmation.
Function version_option Add a ``--version`` option which immediately prints the version number and exits the program.
Constant F Undocumented
Constant FC Undocumented
Variable CmdType Undocumented
Function _param_memo Undocumented
def argument(*param_decls, **attrs): (source)

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
*param_decls:strUndocumented
**attrs:t.AnyUndocumented
Returns
t.Callable[[FC], FC]Undocumented
def command(name=None, cls=None, **attrs): (source)

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[str, t.Callable[..., t.Any], None]Undocumented
cls:t.Optional[t.Type[Command]]Undocumented
**attrs:t.AnyUndocumented
Returns
t.Union[Command, t.Callable[..., Command]]Undocumented
def confirmation_option(*param_decls, **kwargs): (source)

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
*param_decls:strUndocumented
**kwargs:t.AnyUndocumented
Returns
t.Callable[[FC], FC]Undocumented
def group(name=None, **attrs): (source)

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[str, t.Callable[..., t.Any], None]Undocumented
**attrs:t.AnyUndocumented
Returns
t.Union[Group, t.Callable[[F], Group]]Undocumented
def help_option(*param_decls, **kwargs): (source)

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
*param_decls:strUndocumented
**kwargs:t.AnyUndocumented
Returns
t.Callable[[FC], FC]Undocumented
def make_pass_decorator(object_type, ensure=False): (source)

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
object_type:t.TypeUndocumented
ensure:boolUndocumented
Returns
t.Callable[[F], F]Undocumented
def option(*param_decls, **attrs): (source)

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
*param_decls:strUndocumented
**attrs:t.AnyUndocumented
Returns
t.Callable[[FC], FC]Undocumented
def pass_context(f): (source)

Marks a callback as wanting to receive the current context object as first argument.

Parameters
f:FUndocumented
Returns
FUndocumented
def pass_meta_key(key, *, doc_description=None): (source)

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:strUndocumented
doc_description:t.Optional[str]Undocumented
Returns
t.Callable[[F], F]Undocumented
def pass_obj(f): (source)

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.

Parameters
f:FUndocumented
Returns
FUndocumented
def password_option(*param_decls, **kwargs): (source)

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
*param_decls:strUndocumented
**kwargs:t.AnyUndocumented
Returns
t.Callable[[FC], FC]Undocumented
def version_option(version=None, *param_decls, package_name=None, prog_name=None, message=None, **kwargs): (source)

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[str]Undocumented
*param_decls:strUndocumented
package_name:t.Optional[str]Undocumented
prog_name:t.Optional[str]Undocumented
message:t.Optional[str]Undocumented
**kwargs:t.AnyUndocumented
Returns
t.Callable[[FC], FC]Undocumented

Undocumented

Value
t.TypeVar('F',
          bound=t.Callable[..., t.Any])

Undocumented

Value
t.TypeVar('FC',
          bound=t.Union[t.Callable[..., t.Any], Command])
CmdType = (source)

Undocumented

def _param_memo(f, param): (source)

Undocumented

Parameters
f:FCUndocumented
param:ParameterUndocumented