class documentation

class Group(MultiCommand):

View In Hierarchy

A group allows a command to have subcommands attached. This is the most common way to implement nesting in Click.

Changed in version 8.0: The commmands argument can be a list of command objects.
Parameters
nameThe name of the group command.
commandsA dict mapping names to Command objects. Can also be a list of Command, which will use Command.name to create the dict.
**attrsOther command arguments described in MultiCommand, Command, and BaseCommand.
Method __init__ Undocumented
Method add​_command Registers another Command with this group. If the name is not provided, the name of the command is used.
Method command No summary
Method get​_command Given a context and a command name, this returns a Command object if it exists or returns None.
Method group No summary
Method list​_commands Returns a list of subcommand names in the order they should appear.
Class Variable command​_class Undocumented
Class Variable group​_class Undocumented
Instance Variable commands Undocumented

Inherited from MultiCommand:

Method collect​_usage​_pieces Returns all the pieces that go into the usage line and returns it as a list of strings.
Method format​_commands Extra format methods for multi methods that adds all the commands after the options.
Method format​_options Writes all the options into the formatter if they exist.
Method invoke Given a context, this invokes the attached callback (if it exists) in the right way.
Method parse​_args Given a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by make_context.
Method resolve​_command Undocumented
Method result​_callback No summary
Method resultcallback Undocumented
Method shell​_complete Return a list of completions for the incomplete value. Looks at the names of options, subcommands, and chained multi-commands.
Method to​_info​_dict Gather information that could be useful for a tool generating user-facing documentation. This traverses the entire structure below this command.
Class Variable allow​_extra​_args Undocumented
Class Variable allow​_interspersed​_args Undocumented
Instance Variable ​_result​_callback Undocumented
Instance Variable chain Undocumented
Instance Variable invoke​_without​_command Undocumented
Instance Variable no​_args​_is​_help Undocumented
Instance Variable subcommand​_metavar Undocumented

Inherited from Command (via MultiCommand):

Method format​_epilog Writes the epilog into the formatter if it exists.
Method format​_help Writes the help into the formatter if it exists.
Method format​_help​_text Writes the help text to the formatter if it exists.
Method format​_usage Writes the usage line into the formatter.
Method get​_help Formats the help into a string and returns it.
Method get​_help​_option Returns the help option object.
Method get​_help​_option​_names Returns the names for the help option.
Method get​_params Undocumented
Method get​_short​_help​_str Gets short help for the command or makes it by shortening the long help string.
Method get​_usage Formats the usage line into a string and returns it.
Method make​_parser Creates the underlying option parser for this command.
Instance Variable add​_help​_option Undocumented
Instance Variable callback Undocumented
Instance Variable deprecated Undocumented
Instance Variable epilog Undocumented
Instance Variable help Undocumented
Instance Variable hidden Undocumented
Instance Variable options​_metavar Undocumented
Instance Variable params Undocumented
Instance Variable short​_help Undocumented

Inherited from BaseCommand (via MultiCommand, Command):

Method __call__ Alias for main.
Method __repr__ Undocumented
Method ​_main​_shell​_completion Check if the shell is asking for tab completion, process that, then exit early. Called from main before the program is invoked.
Method main No summary
Method make​_context This function when given an info name and arguments will kick off the parsing and create a new Context. It does not invoke the actual command callback though.
Class Variable ignore​_unknown​_options Undocumented
Instance Variable context​_settings Undocumented
Instance Variable name Undocumented
def __init__(self, name=None, commands=None, **attrs):

Undocumented

Parameters
name:t.Optional[str]Undocumented
commands:t.Optional[t.Union[t.Dict[str, Command], t.Sequence[Command]]]Undocumented
**attrs:t.AnyUndocumented
def add_command(self, cmd, name=None):
Registers another Command with this group. If the name is not provided, the name of the command is used.
Parameters
cmd:CommandUndocumented
name:t.Optional[str]Undocumented
def command(self, *args, **kwargs):

A shortcut decorator for declaring and attaching a command to the group. This takes the same arguments as command and immediately registers the created command with this group by calling add_command.

To customize the command class used, set the command_class attribute.

Changed in version 8.0: Added the command_class attribute.
Parameters
*args:t.AnyUndocumented
**kwargs:t.AnyUndocumented
Returns
t.Callable[[t.Callable[..., t.Any]], Command]Undocumented
def get_command(self, ctx, cmd_name):
Given a context and a command name, this returns a Command object if it exists or returns None.
Parameters
ctx:ContextUndocumented
cmd​_name:strUndocumented
Returns
t.Optional[Command]Undocumented
def group(self, *args, **kwargs):

A shortcut decorator for declaring and attaching a group to the group. This takes the same arguments as group and immediately registers the created group with this group by calling add_command.

To customize the group class used, set the group_class attribute.

Changed in version 8.0: Added the group_class attribute.
Parameters
*args:t.AnyUndocumented
**kwargs:t.AnyUndocumented
Returns
t.Callable[[t.Callable[..., t.Any]], Group]Undocumented
def list_commands(self, ctx):
Returns a list of subcommand names in the order they should appear.
Parameters
ctx:ContextUndocumented
Returns
t.List[str]Undocumented
command_class: t.Optional[t.Type[Command]] =

Undocumented

group_class: t.Optional[t.Union[t.Type[Group], t.Type[type]]] =

Undocumented

commands: t.Dict[str, Command] =

Undocumented