Class ConsoleCommandManager
java.lang.Object
com.dianxin.tori.base.console.commands.ConsoleCommandManager
Manages the registration, parsing, and execution routing of console commands.
It listens to standard input (System.in) on a separate background thread.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDispatches and executes a command string directly.voidregister(AbstractConsoleCommand command) Registers a new console command.voidregister(AbstractConsoleCommand cmd, boolean willPrintLog) Registers a console command with a flag to determine explicit log output.voidInitializes and starts a background thread that continuously reads inputs from standard input (System.in) and routes them to their registered commands.
-
Constructor Details
-
ConsoleCommandManager
public ConsoleCommandManager()
-
-
Method Details
-
register
Registers a new console command. Logging behavior defaults to standard reporting.- Parameters:
command- the console command instance to register
-
register
Registers a console command with a flag to determine explicit log output. Maps the command using its lower-case command identifier as the unique key.- Parameters:
cmd- the console command instance to registerwillPrintLog- flag to indicate whether specific debug logs should be printed
-
dispatch
Dispatches and executes a command string directly. Can be invoked from CLI console thread, GUI inputs, or remote APIs.- Parameters:
rawLine- the full raw command string (e.g., "stop", "bots")
-
startListening
public void startListening()Initializes and starts a background thread that continuously reads inputs from standard input (System.in) and routes them to their registered commands.
-