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
| 1585 | |
| 1586 | |
| 1587 | class 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 |
no outgoing calls
searching dependent graphs…