MCPcopy
hub / github.com/pallets/click / Group

Class Group

src/click/core.py:1587–2047  ·  view source on GitHub ↗

A group is a command that nests other commands (or more groups). :param name: The name of the group command. :param commands: Map names to :class:`Command` objects. Can be a list, which will use :attr:`Command.name` as the keys. :param invoke_without_command: Invoke the group's

Source from the content-addressed store, hash-verified

1585
1586
1587class Group(Command):
1588 """A group is a command that nests other commands (or more groups).
1589
1590 :param name: The name of the group command.
1591 :param commands: Map names to :class:`Command` objects. Can be a list, which
1592 will use :attr:`Command.name` as the keys.
1593 :param invoke_without_command: Invoke the group's callback even if a
1594 subcommand is not given.
1595 :param no_args_is_help: If no arguments are given, show the group's help and
1596 exit. Defaults to the opposite of ``invoke_without_command``.
1597 :param subcommand_metavar: How to represent the subcommand argument in help.
1598 The default will represent whether ``chain`` is set or not.
1599 :param chain: Allow passing more than one subcommand argument. After parsing
1600 a command's arguments, if any arguments remain another command will be
1601 matched, and so on.
1602 :param result_callback: A function to call after the group's and
1603 subcommand's callbacks. The value returned by the subcommand is passed.
1604 If ``chain`` is enabled, the value will be a list of values returned by
1605 all the commands. If ``invoke_without_command`` is enabled, the value
1606 will be the value returned by the group's callback, or an empty list if
1607 ``chain`` is enabled.
1608 :param kwargs: Other arguments passed to :class:`Command`.
1609
1610 .. versionchanged:: 8.0
1611 The ``commands`` argument can be a list of command objects.
1612
1613 .. versionchanged:: 8.2
1614 Merged with and replaces the ``MultiCommand`` base class.
1615 """
1616
1617 allow_extra_args = True
1618 allow_interspersed_args = False
1619
1620 #: If set, this is used by the group's :meth:`command` decorator
1621 #: as the default :class:`Command` class. This is useful to make all
1622 #: subcommands use a custom command class.
1623 #:
1624 #: .. versionadded:: 8.0
1625 command_class: type[Command] | None = None
1626
1627 #: If set, this is used by the group's :meth:`group` decorator
1628 #: as the default :class:`Group` class. This is useful to make all
1629 #: subgroups use a custom group class.
1630 #:
1631 #: If set to the special value :class:`type` (literally
1632 #: ``group_class = type``), this group's class will be used as the
1633 #: default class. This makes a custom group class continue to make
1634 #: custom groups.
1635 #:
1636 #: .. versionadded:: 8.0
1637 group_class: type[Group] | type[type] | None = None
1638 # Literal[type] isn't valid, so use Type[type]
1639
1640 commands: cabc.MutableMapping[str, Command]
1641 invoke_without_command: bool
1642 subcommand_metavar: str
1643 chain: bool
1644 _result_callback: t.Callable[..., t.Any] | None

Callers 11

test_groupFunction · 0.90
test_nested_groupFunction · 0.90
test_chainedFunction · 0.90
test_help_optionFunction · 0.90
test_hiddenFunction · 0.90
test_add_different_nameFunction · 0.90
test_full_sourceFunction · 0.90
test_full_completeFunction · 0.90

Calls

no outgoing calls

Tested by 11

test_groupFunction · 0.72
test_nested_groupFunction · 0.72
test_chainedFunction · 0.72
test_help_optionFunction · 0.72
test_hiddenFunction · 0.72
test_add_different_nameFunction · 0.72
test_full_sourceFunction · 0.72
test_full_completeFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…