Class SystemRegistryImpl

java.lang.Object
org.jline.console.impl.SystemRegistryImpl
All Implemented Interfaces:
ConsoleOptionGetter, CommandRegistry, SystemRegistry

public class SystemRegistryImpl extends Object implements SystemRegistry
Aggregate command registries.
Author:
Matti Rinta-Nikkola
  • Field Details

  • Constructor Details

  • Method Details

    • rename

      public void rename(SystemRegistryImpl.Pipe pipe, String name)
    • getPipeNames

      public Collection<String> getPipeNames()
      Specified by:
      getPipeNames in interface SystemRegistry
      Returns:
      pipe names defined in systemRegistry
    • setCommandRegistries

      public void setCommandRegistries(CommandRegistry... commandRegistries)
      Description copied from interface: SystemRegistry
      Set command registries
      Specified by:
      setCommandRegistries in interface SystemRegistry
      Parameters:
      commandRegistries - command registries used by the application
    • initialize

      public void initialize(File script)
      Description copied from interface: SystemRegistry
      Initialize consoleEngine environment by executing console script
      Specified by:
      initialize in interface SystemRegistry
      Parameters:
      script - initialization script
    • 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
    • consoleOption

      public Object consoleOption(String name)
      Description copied from interface: SystemRegistry
      Return console option value
      Specified by:
      consoleOption in interface ConsoleOptionGetter
      Specified by:
      consoleOption in interface SystemRegistry
      Parameters:
      name - the option name
      Returns:
      option value
    • consoleOption

      public <T> T consoleOption(String name, T defVal)
      Description copied from interface: SystemRegistry
      Return console option value
      Specified by:
      consoleOption in interface ConsoleOptionGetter
      Specified by:
      consoleOption in interface SystemRegistry
      Type Parameters:
      T - option type
      Parameters:
      name - the option name
      defVal - value to return if console option does not exists
      Returns:
      option value
    • setConsoleOption

      public void setConsoleOption(String name, Object value)
      Description copied from interface: SystemRegistry
      Set console option value
      Specified by:
      setConsoleOption in interface SystemRegistry
      Parameters:
      name - the option name
      value - value to assign console option
    • register

      public void register(String command, CommandRegistry subcommandRegistry)
      Register subcommand registry
      Specified by:
      register in interface SystemRegistry
      Parameters:
      command - main command
      subcommandRegistry - subcommand registry
    • 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
    • setGroupCommandsInHelp

      public void setGroupCommandsInHelp(boolean commandGroups)
    • groupCommandsInHelp

      public SystemRegistryImpl groupCommandsInHelp(boolean commandGroups)
    • isCommandOrScript

      public boolean isCommandOrScript(ParsedLine line)
      Description copied from interface: SystemRegistry
      Returns whether a line contains command/script that is known to this registry.
      Specified by:
      isCommandOrScript in interface SystemRegistry
      Parameters:
      line - the parsed command line to test
      Returns:
      true if the specified line has a command registered
    • isCommandOrScript

      public boolean isCommandOrScript(String command)
      Description copied from interface: SystemRegistry
      Returns whether command is known to this registry.
      Specified by:
      isCommandOrScript in interface SystemRegistry
      Parameters:
      command - the command to test
      Returns:
      true if the specified command is known
    • addCompleter

      public void addCompleter(Completer completer)
    • 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
    • completer

      public Completer completer()
      Description copied from interface: SystemRegistry
      Returns command completer that includes also console variable and script completion.
      Specified by:
      completer in interface SystemRegistry
      Returns:
      command completer
    • 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.
    • setScriptDescription

      public void setScriptDescription(Function<CmdLine,CmdDesc> scriptDescription)
    • commandDescription

      public CmdDesc commandDescription(CmdLine line)
      Description copied from interface: SystemRegistry
      Returns a command, method or syntax description for use in the JLine Widgets framework.
      Specified by:
      commandDescription in interface SystemRegistry
      Parameters:
      line - command line whose description to return
      Returns:
      command description for JLine TailTipWidgets to be displayed in the terminal status bar.
    • invoke

      public Object invoke(String command, Object... args) throws Exception
      Description copied from interface: SystemRegistry
      Execute command with arguments
      Specified by:
      invoke in interface SystemRegistry
      Parameters:
      command - command to be executed
      args - arguments of the command
      Returns:
      command execution result
      Throws:
      Exception - in case of error
    • terminal

      public Terminal terminal()
      Specified by:
      terminal in interface SystemRegistry
      Returns:
      terminal
    • isCommandAlias

      public boolean isCommandAlias(String command)
      Description copied from interface: SystemRegistry
      Returns whether alias is known command alias.
      Specified by:
      isCommandAlias in interface SystemRegistry
      Parameters:
      command - the alias to test
      Returns:
      true if the alias is known command alias
    • execute

      public Object execute(String line) throws Exception
      Description copied from interface: SystemRegistry
      Execute a command, script or evaluate scriptEngine statement
      Specified by:
      execute in interface SystemRegistry
      Parameters:
      line - command line to be executed
      Returns:
      execution result
      Throws:
      Exception - in case of error
    • cleanUp

      public void cleanUp()
      Description copied from interface: SystemRegistry
      Delete temporary console variables and reset output streams
      Specified by:
      cleanUp in interface SystemRegistry
    • trace

      public void trace(Throwable exception)
      Description copied from interface: SystemRegistry
      Print exception on terminal
      Specified by:
      trace in interface SystemRegistry
      Parameters:
      exception - exception to print on terminal
    • trace

      public void trace(boolean stack, Throwable exception)
      Description copied from interface: SystemRegistry
      Print exception on terminal
      Specified by:
      trace in interface SystemRegistry
      Parameters:
      stack - print stack trace if stack true otherwise message
      exception - exception to be printed
    • close

      public void close()
      Description copied from interface: SystemRegistry
      Orderly close SystemRegistry.
      Specified by:
      close in interface SystemRegistry
    • consoleEngine

      public ConsoleEngine consoleEngine()