cloup._commands

Classes summary

cloup._commands.Command(*args, **kwargs)

A click.Command supporting option groups.

cloup._commands.MultiCommand(*args, **kwargs)

A click.MultiCommand that allows to organize its subcommands in multiple help sections and and whose subcommands are, by default, of type cloup.Command.

cloup._commands.Group([name, commands, …])

A click.Group that allows to organize its subcommands in multiple help sections and and whose subcommands are, by default, of type cloup.Command.

Functions Summary

cloup._commands.group([name, cls])

Creates a new Group using the decorated function as callback. This is just a convenience function equivalent to::.

cloup._commands.command([name, cls])

Decorator that creates a new command using the wrapped function as callback.

Contents

class cloup._commands.Command(*args, **kwargs)[source]

Bases: cloup.constraints.ConstraintMixin, cloup._option_groups.OptionGroupMixin, click.Command

A click.Command supporting option groups. This class is obtained by mixing click.Command with cloup.OptionGroupMixin.

class cloup._commands.MultiCommand(*args, **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 type cloup.Command.

This class is just a click.MultiCommand mixed with SectionMixin. See the docstring of the two superclasses for more details.

class cloup._commands.Group(name: Optional[str] = None, commands: Optional[Dict[str, click.Command]] = None, sections: Iterable[Section] = (), align_sections: bool = 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 type cloup.Command.

This class is just a click.Group mixed with SectionMixin that overrides the decorators command() and group() so that a section for the created subcommand can be specified.

See the docstring of the two superclasses for more details.

Parameters
command(self, name: Optional[str] = None, section: Optional[Section] = None, cls: Optional[Type[click.Command]] = None, **attrs)[source]

Creates a new command and adds it to this group.

Parameters
group(self, name: Optional[str] = None, section: Optional[Section] = None, cls: Optional[Type[click.Group]] = None, **attrs)[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 into add_command().

Parameters
cloup._commands.group(name: Optional[str] = None, cls: Type[click.Group] = Group, **attrs)[source]

Creates a new Group using the decorated function as callback. This is just a convenience function equivalent to:

click.group(name, cls=cloup.Group, **attrs)
Parameters
  • name (Optional[str]) – name of the command

  • cls (Type[click.core.Group]) – type of Group

  • attrs – any argument you can pass to click.group()

cloup._commands.command(name: Optional[str] = None, cls: Type[click.Command] = 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()