commands
The commands module offers functions and types for adding new Command instances
to mudpuppy. Typically these are called "slash commands" since the default command
prefix is a / character.
Commands are an alternative to mudpuppy_core.Alias instances and are helpful if you
want to do more complex argument parsing.
An async function that is called when input sent to a MUD matches the command prefix
and name of a command. Typically you will assign a CommandCallable to the handler
property of a Command.
The handler is called with:
- the
intsession ID of the session that received the input. - an
argparse.Namespacewith parsed arguments.
An instance of a Mudpuppy "slash command".
See add_command().
Create an instance of a Command that is run for /$NAME.
name- The name of the command. This is what the user will type to trigger the command. E.g./$NAMEsession- The session ID that the command should be associated with usingadd_command().`handler- aCommandCallableto invoke when the command is run.description- An optional description of the command that can be shown in a command list.aliases- An optional list of other names the command should respond to in addition toname.
An argparse.ArgumentParser that is used to parse arguments for this command.
It is created with exit_on_error=False and add_help=False to allow for custom
error handling and help display.
Invoke the command for the provided sesh_id by parsing args with the Command's
parser.
Register the given Command as usable by the given sesh_id.
Returns a list of all Commands that have been registered for the given sesh_id
with add_command().