tuxemon.cli.clicommand module

class tuxemon.cli.clicommand.CLICommand[source]

Bases: ABC

Base class for CLIOptions.

description: ClassVar[str] = 'command description'
example: ClassVar[str] = ''
get_parameters(ctx)[source]

Return parameters for use by help or autocomplete.

Parameters:

ctx (InvokeContext) – Contains references to parts of the game and CLI interface.

Return type:

Iterable[Parameter]

get_subcommand(ctx, name)[source]

Return a single subcommand by name.

If not implemented by subclass, then this will do a simple search by name of all subcommands as returned by self.get_subcommands.

Parameters:
  • ctx (InvokeContext) – Contains references to parts of the game and CLI interface.

  • name (str) – Name of the action, in the form that it would be typed.

Raises:

CommandNotFoundError – If command by name is not found.

Return type:

CLICommand

get_subcommands(ctx)[source]

Return all subcommands of this command.

Parameters:

ctx (InvokeContext) – Contains references to parts of the game and CLI interface.

Return type:

Iterable[CLICommand]

invoke(ctx, line)[source]

Called when command input contains this command name as first term.

Parameters:
  • ctx (InvokeContext) – Contains references to parts of the game and CLI interface.

  • line (str) – Input text after the command name.

Return type:

None

name: ClassVar[str] = 'command name'
resolve(ctx, path)[source]

Resolve a path into command and remaining text.

  • Split the command into tokens.

  • Starting from the first token, search it for the next token.

  • If the next token is a subcommand, repeat.

  • If the next token is not a subcommand, return command and the rest of the input.

For example:

The string “action npc_face player up” will be parsed by checking each CLICommand for sub commands in a graph search. Starting at the root, which is unnamed, it will have an “action” command. Then searching “action”, it will have “npc_face”. npc_face is a command, but doesn’t have “player” as a subcommand, so the remaining portion of the string will be treated as an argument to “npc_face”.

Parameters:
Return type:

Tuple[CLICommand, str]

usable_from_root: ClassVar[bool] = True