instrukt.commands.command
.CmdGroup
- class instrukt.commands.command.CmdGroup(name: str, description: str, parent: CmdGroup | None = None)[source]
Bases:
object
A class representing a group of commands.
Methods
__init__
(name, description[, parent])add_command
(command[, override])Add a Command or CmdGroup to this group.
command
([_func, name, description, alias])Decorator that registers a function as a command in a CommandGroup.
execute
(ctx[, command_string])Execute a command given a string.
get_command
(name, /)Retrive a command or a group from its name or alias.
group
([_cls, name, description])Decorator that registers a class as a command group.
help
()Generate the help for the current group.
parse_cmd
(cmd_list)Given a commands string, return the command or group that matches the string.
Iterator that recursively walks through all commands that this group contains.
Attributes
The commands that this group contains.
Return the root parent of this group.
- add_command(command: Command | CmdGroup, override: bool = False) None [source]
Add a Command or CmdGroup to this group.
- command(_func=None, *, name: str | None = None, description: str | None = None, alias: str | None = None) Callable[[Callable[[...], Awaitable[Any | None]]], Callable[[...], Awaitable[Any | None]]] [source]
Decorator that registers a function as a command in a CommandGroup.
- async execute(ctx: Context, command_string: str | None = None, **kwargs) Any | Awaitable[Any | None] [source]
Execute a command given a string.
Parses the command string recursively and executes the leaf command.
- get_command(name: str, /) Command | CmdGroup | None [source]
Retrive a command or a group from its name or alias.
- group(_cls=None, *, name: str = <MISSING>, description: str = <MISSING>) Callable[[...], Any] [source]
Decorator that registers a class as a command group.
- help() str [source]
Generate the help for the current group.
List all the commands under the current group and their description.
If the group is the root group, then it will list all the commands.
- parse_cmd(cmd_list: str) Command | CmdGroup | None [source]
Given a commands string, return the command or group that matches the string.
- walk_commands() Generator[Command | CmdGroup, None, None] [source]
Iterator that recursively walks through all commands that this group contains.
- property is_root: bool