|
OpenQuizz
Une application de gestion des contenus pédagogiques
|
Functions | |
| def | pass_context (f) |
| def | pass_obj (f) |
| def | make_pass_decorator (object_type, ensure=False) |
| def | command (name=None, cls=None, **attrs) |
| def | group (name=None, **attrs) |
| def | argument (*param_decls, **attrs) |
| def | option (*param_decls, **attrs) |
| def | confirmation_option (*param_decls, **attrs) |
| def | password_option (*param_decls, **attrs) |
| def | version_option (version=None, *param_decls, **attrs) |
| def | help_option (*param_decls, **attrs) |
| def click.decorators.argument | ( | * | param_decls, |
| ** | attrs | ||
| ) |
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`.
| def click.decorators.command | ( | name = None, |
|
cls = None, |
|||
| ** | attrs | ||
| ) |
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.
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`.
| def click.decorators.confirmation_option | ( | * | param_decls, |
| ** | attrs | ||
| ) |
Shortcut for confirmation prompts that can be ignored by passing
``--yes`` as parameter.
This is equivalent to decorating a function with :func:`option` with
the following parameters::
def callback(ctx, param, value):
if not value:
ctx.abort()
@click.command()
@click.option('--yes', is_flag=True, callback=callback,
expose_value=False, prompt='Do you want to continue?')
def dropdb():
pass
| def click.decorators.group | ( | name = None, |
|
| ** | attrs | ||
| ) |
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`.
| def click.decorators.help_option | ( | * | param_decls, |
| ** | attrs | ||
| ) |
Adds a ``--help`` option which immediately ends the program printing out the help page. This is usually unnecessary to add as this is added by default to all commands unless suppressed. Like :func:`version_option`, this is implemented as eager option that prints in the callback and exits. All arguments are forwarded to :func:`option`.
| def click.decorators.make_pass_decorator | ( | object_type, | |
ensure = False |
|||
| ) |
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.
| def click.decorators.option | ( | * | param_decls, |
| ** | attrs | ||
| ) |
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`.
| def click.decorators.pass_context | ( | f | ) |
Marks a callback as wanting to receive the current context object as first argument.
| def click.decorators.pass_obj | ( | f | ) |
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.
| def click.decorators.password_option | ( | * | param_decls, |
| ** | attrs | ||
| ) |
Shortcut for password prompts.
This is equivalent to decorating a function with :func:`option` with
the following parameters::
@click.command()
@click.option('--password', prompt=True, confirmation_prompt=True,
hide_input=True)
def changeadmin(password):
pass
| def click.decorators.version_option | ( | version = None, |
|
| * | param_decls, | ||
| ** | attrs | ||
| ) |
Adds a ``--version`` option which immediately ends the program
printing out the version number. This is implemented as an eager
option that prints the version and exits the program in the callback.
:param version: the version number to show. If not provided Click
attempts an auto discovery via setuptools.
:param prog_name: the name of the program (defaults to autodetection)
:param message: custom message to show instead of the default
(``'%(prog)s, version %(version)s'``)
:param others: everything else is forwarded to :func:`option`.