Class AbstractCommandRegistry

java.lang.Object
org.jline.console.impl.AbstractCommandRegistry
All Implemented Interfaces:
CommandRegistry
Direct Known Subclasses:
JlineCommandRegistry

public abstract class AbstractCommandRegistry extends Object implements CommandRegistry
Abstract base class implementing common methods for command registries.

AbstractCommandRegistry provides a base implementation of the CommandRegistry interface, with common methods for registering commands, generating command descriptions, and handling command execution. Concrete implementations can extend this class to create specific command registry types.

  • Constructor Details

    • AbstractCommandRegistry

      public AbstractCommandRegistry()
      Creates a new AbstractCommandRegistry. The command registry is initialized lazily when commands are registered.
  • Method Details

    • doHelpDesc

      public CmdDesc doHelpDesc(String command, List<String> info, CmdDesc cmdDesc)
      Creates a command description for a help command.

      This method combines the command information with the command description to create a comprehensive help description for the command.

      Parameters:
      command - the command name
      info - the command information as a list of strings
      cmdDesc - the command description
      Returns:
      a command description for the help command
    • registerCommands

      public <T extends Enum<T>> void registerCommands(Map<T,String> commandName, Map<T,CommandMethods> commandExecute)
    • registerCommands

      public void registerCommands(Map<String,CommandMethods> commandExecute)
    • invoke

      public Object invoke(CommandRegistry.CommandSession session, String command, Object... args) throws Exception
      Description copied from interface: CommandRegistry
      Execute a command.
      Specified by:
      invoke in interface CommandRegistry
      Parameters:
      session - the data of the current command session
      command - the name of the command
      args - arguments of the command
      Returns:
      result of the command execution
      Throws:
      Exception - in case of error
    • saveException

      public void saveException(Exception exception)
    • hasCommand

      public boolean hasCommand(String command)
      Description copied from interface: CommandRegistry
      Returns whether a command with the specified name is known to this registry.
      Specified by:
      hasCommand in interface CommandRegistry
      Parameters:
      command - the command name to test
      Returns:
      true if the specified command is registered
    • commandNames

      public Set<String> commandNames()
      Description copied from interface: CommandRegistry
      Returns the command names known by this registry.
      Specified by:
      commandNames in interface CommandRegistry
      Returns:
      the set of known command names, excluding aliases
    • commandAliases

      public Map<String,String> commandAliases()
      Description copied from interface: CommandRegistry
      Returns a map of alias-to-command names known by this registry.
      Specified by:
      commandAliases in interface CommandRegistry
      Returns:
      a map with alias keys and command name values
    • rename

      public <V extends Enum<V>> void rename(V command, String newName)
    • alias

      public void alias(String alias, String command)
    • compileCompleters

      public SystemCompleter compileCompleters()
      Description copied from interface: CommandRegistry
      Returns a SystemCompleter that can provide detailed completion information for all registered commands.
      Specified by:
      compileCompleters in interface CommandRegistry
      Returns:
      a SystemCompleter that can provide command completion for all registered commands
    • getCommandMethods

      public CommandMethods getCommandMethods(String command)
    • registeredCommand

      public Object registeredCommand(String command)