Class CommandRegistryAdapter

java.lang.Object
org.jline.console.impl.CommandRegistryAdapter
All Implemented Interfaces:
CommandRegistry

public class CommandRegistryAdapter extends Object implements CommandRegistry
Adapts a new CommandGroup to the old CommandRegistry interface.

This bridge allows new-style command groups to be used with the legacy SystemRegistryImpl and other old API consumers.

Since:
4.0
See Also:
  • Constructor Details

    • CommandRegistryAdapter

      public CommandRegistryAdapter(org.jline.shell.CommandGroup group)
      Creates an adapter wrapping the given command group.
      Parameters:
      group - the new command group to adapt
  • Method Details

    • name

      public String name()
      Description copied from interface: CommandRegistry
      Returns the name of this registry.
      Specified by:
      name in interface CommandRegistry
      Returns:
      the name of the registry
    • 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
    • commandInfo

      public List<String> commandInfo(String command)
      Description copied from interface: CommandRegistry
      Returns a short info about command known by this registry.
      Specified by:
      commandInfo in interface CommandRegistry
      Parameters:
      command - the command name
      Returns:
      a short info about command
    • 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
    • compileCompleters

      public org.jline.reader.impl.completer.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
    • commandDescription

      public CmdDesc commandDescription(List<String> args)
      Description copied from interface: CommandRegistry
      Returns a command description for use in the JLine Widgets framework. Default method must be overridden to return sub command descriptions.
      Specified by:
      commandDescription in interface CommandRegistry
      Parameters:
      args - command (args[0]) and its arguments
      Returns:
      command description for JLine TailTipWidgets to be displayed in the terminal status bar.
    • 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