cloup._commands
¶
Classes summary¶
|
A |
|
A |
|
A |
Functions Summary¶
|
Decorator for creating a new |
|
Decorator that creates a new command using the wrapped function as callback. |
Contents¶
-
class
cloup._commands.
Command
(*click_args, constraints=(), show_constraints=False, align_option_groups=True, **click_kwargs)[source]¶ Bases:
cloup.constraints.ConstraintMixin
,cloup._option_groups.OptionGroupMixin
,click.Command
A
click.Command
supporting option groups and constraints.- Parameters
constraints (Sequence[cloup.constraints._support.BoundConstraintSpec]) –
show_constraints (bool) –
align_option_groups (bool) –
-
class
cloup._commands.
MultiCommand
(*args, commands=None, sections=(), align_sections=True, **kwargs)[source]¶ Bases:
cloup._sections.SectionMixin
,click.MultiCommand
A
click.MultiCommand
that allows to organize its subcommands in multiple help sections and and whose subcommands are, by default, of typecloup.Command
.This class is just a
click.MultiCommand
mixed withSectionMixin
. See the docstring of the two superclasses for more details.- Parameters
commands (Optional[Dict[str, click.core.Command]]) –
sections (Iterable[cloup._sections.Section]) –
align_sections (bool) –
-
class
cloup._commands.
Group
(name=None, commands=None, sections=(), align_sections=True, **attrs)[source]¶ Bases:
cloup._sections.SectionMixin
,click.Group
A
click.Group
that allows to organize its subcommands in multiple help sections and and whose subcommands are, by default, of typecloup.Command
.This class is just a
click.Group
mixed withSectionMixin
that overrides the decoratorscommand()
andgroup()
so that asection
for the created subcommand can be specified.See the docstring of the two superclasses for more details.
- Parameters
name (Optional[str]) –
commands (Optional[Dict[str, click.core.Command]]) –
sections (Iterable[cloup._sections.Section]) –
align_sections (bool) –
-
command
(self, name=None, cls=None, section=None, **kwargs)[source]¶ Creates a new command and adds it to this group.
- Parameters
name (Optional[str]) –
cls (Optional[Type[click.Command]]) –
section (Optional[cloup._sections.Section]) –
- Return type
Callable[[Callable], click.Command]
-
group
(self, name=None, cls=None, section=None, **kwargs)[source]¶ A shortcut decorator for declaring and attaching a group to the group. This takes the same arguments as
group()
but immediately registers the created command with this instance by calling intoadd_command()
.- Parameters
name (Optional[str]) –
cls (Optional[Type[click.Group]]) –
section (Optional[cloup._sections.Section]) –
-
cloup._commands.
group
(name=None, cls=Group, **attrs)[source]¶ Decorator for creating a new
Group
.Note
If you use static type checking, note that the
cls
optional argument of this function must be of typecloup.Group
, notclick.Group
.- Parameters
name (Optional[str]) – name of the command
cls (Type[cloup._commands.Group]) – type of
cloup.Group
attrs – any argument you can pass to
click.group()
- Return type
Callable[[Callable], cloup._commands.Group]
-
cloup._commands.
command
(name=None, cls=Command, **attrs)[source]¶ Decorator that creates a new command using the wrapped function as callback.
The only differences with respect to
click.commands
are:this decorator creates a
cloup.Command
by default;this decorator supports
@constraint
.
- Parameters
name (Optional[str]) – name of the command
cls (Type[click.core.Command]) – type of click.Command
attrs – any argument you can pass to
click.command()
- Return type
Callable[[Callable], click.core.Command]