Class ConsoleCommandManager

java.lang.Object
com.dianxin.tori.base.console.commands.ConsoleCommandManager

public class ConsoleCommandManager extends Object
Manages the registration, parsing, and execution routing of console commands. It listens to standard input (System.in) on a separate background thread.
  • Constructor Details

    • ConsoleCommandManager

      public ConsoleCommandManager()
  • Method Details

    • register

      public void register(AbstractConsoleCommand command)
      Registers a new console command. Logging behavior defaults to standard reporting.
      Parameters:
      command - the console command instance to register
    • register

      public void register(AbstractConsoleCommand cmd, boolean willPrintLog)
      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 register
      willPrintLog - flag to indicate whether specific debug logs should be printed
    • dispatch

      public void dispatch(String rawLine)
      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.