command_line module¶
Contains the required classes and various utility methods to allow the addition of 3rd party commands into the command-line portion of the editor.
-
class
command_line.command_api.
ComplexCommand
(cmd_handler)[source]¶ Bases:
command_line.command_api._CommandBase
Represents a base command that holds sub-commands
-
classmethod
get_subclasses
()[source]¶ Utility function to get all classes that extend this one
Return type: List
[Type
[ComplexCommand
]]Returns: A list of all subclasses
-
classmethod
help
(command_name=None)[source]¶ Abstract method that prints a detailed description of all the commands held by the base command if called with default arguments. If help is called on a specific command, the subcommand’s name will supplied with command_name
This method expects all information to be printed, nothing returned will be used
Parameters: command_name – The name/identifier of the specific command help was called on, None if help was called on the base command of the ComplexCommand
-
classmethod
-
class
command_line.command_api.
Mode
(cmd_line_handler)[source]¶ Bases:
object
Represents a configurable state that the command line can enter. This is useful for controlling the execution of various commands
-
before_execution
(command)[source]¶ Called before the execution of a command. Return True to run the given command, False to halt the execution.
Parameters: command ( List
[str
]) – The command that is to be executedReturn type: bool
-
-
class
command_line.command_api.
SimpleCommand
(cmd_handler)[source]¶ Bases:
command_line.command_api._CommandBase
Represents a command that can be executed within the command line
-
classmethod
get_subclasses
()[source]¶ Utility function to get all classes that extend this one
Return type: List
[Type
[SimpleCommand
]]Returns: A list of all subclasses
-
help
()[source]¶ Abstract method for displaying a detailed help message about the command
This method expects all information to be printed, nothing returned will be used
-
classmethod
-
class
command_line.command_api.
WorldMode
(cmd_line_handler, **kwargs)[source]¶ Bases:
command_line.command_api.Mode
-
before_execution
(cmd)[source]¶ Called before the execution of a command. Return True to run the given command, False to halt the execution.
Parameters: command – The command that is to be executed Return type: bool
-
-
class
command_line.command_api.
_CommandBase
(cmd_handler)[source]¶ Bases:
object
Abstract class that both
SimpleCommand
andComplexCommand
inherit fromNote: Any class that inherits this class won’t be registered as a command, you must inherit from
SimpleCommand
orComplexCommand
-
error
(message)[source]¶ Utility method for printing an error message
Parameters: message ( Any
) – The error message
-
get_mode
(mode_class)[source]¶ Method for getting a Mode that the program is in
Parameters: mode_class ( Type
[Mode
]) – The class of the Mode instance to getReturn type: Mode
Returns: The instance of the specified Mode, None if the mode hasn’t been entered
Allows parsing and access to the shared data pool from a data accessor entry marked by a
$
Parameters: entry_path ( str
) – The path to search for an entry, can start with a “$” but isn’t required toReturn type: Optional
[object
]Returns: The value stored at the entry path, or None if the entry path couldn’t be found
-
-
command_line.command_api.
command
(command_name)[source]¶ Registers a class as a command. If the class’ parent is SimpleCommand, then it will use the abstracted methods. If the class’ parent is ComplexCommand, then any method decorated with the subcommand decorator is registered as a sub-command of the given command name.
Parameters: command_name ( str
) – The name used to identify the command, or the base command if using ComplexCommandReturn type: Type
[Union
[SimpleCommand
,ComplexCommand
]]