Module rpu.cli

Classes

class Command (*, name: str, description: str, brief: str, callback: Callable, aliases: Optional[list[str]] = ...)

Creates a command object

Parameters

name : str
The commands name
description : str
The commands long description
brief : str
a brief description for the command
callback : typing.Callable
The commands callback
aliases : Optional[list[str]]
The commands aliases

Attributes

name : str
The commands name
description : str
The commands long description
brief : str
a brief description for the command
callback : typing.Callable
The commands callback
aliases : list[str]
The commands aliases
exes : list[str]
the commands aliases, but it also has the commands name
class ConsoleClient (*, help_command: Optional[Command] = ...)

Creates a CLI console client

Parameters

help_command : Optional[cli.Command]
An optional help_command. if not supplied, default one will be used

Attributes

help_command : cli.Command
The help command
commands : list[cli.Command]
A list of all commands

Methods

def command(self, *, name: Optional[str] = ..., description: Optional[str] = ..., brief: Optional[str] = ..., aliases: Optional[list[str]] = ...)

|decorator|

Turns a function into a cli.Command object, and auto-adds it to the client

Parameters

name : Optional[str]
The commands name. if not given, it will use the functions name
description : Optional[str]
The commands description. If not given, will be the functions docstring
brief : Optional[str]
The commands brief description.
aliases : Optional[list[str]]
The commands aliases
def dispatch(self, event_name: str, /, *args: Any, **kwargs: Any) ‑> None
def event(self, func)

|decorator|

Creates an event by overriding the events name

def on_arg_not_given(self, command: str, arg: str) ‑> None

This function gets called when a required arg was not given during the execution of a command

This is an event, and thus can be overrided

Parameters

command : str
the commands name
arg : str
the argument that was not supplied
def on_command_error(self, command: str, error: Exception) ‑> None

This function gets called when an error happens during the execution of a command

This is an event, and thus can be overrided

Parameters

command : str
the commands name
error : Exception
The error
def on_command_not_found(self, command: str) ‑> None

This function gets called when the client can not find the specificed command

This is an event, and thus can be overrided

Parameters

command : str
the commands name
def on_extra_arg_given(self, command: str) ‑> None

This function gets called when an extra arg was given when executing a command

This is an event, and thus can be overrided

Parameters

command : str
the commands name
def run(self)

Starts the client