Package org.apache.groovy.groovysh.jline

# Class SystemRegistryImpl

java.lang.Object
org.apache.groovy.groovysh.jline.SystemRegistryImpl

All Implemented Interfaces:
  `org.jline.builtins.ConsoleOptionGetter`, `org.jline.console.CommandRegistry`, `org.jline.console.SystemRegistry`

public class SystemRegistryImpl extends Object implements org.jline.console.SystemRegistry
Aggregate command registries.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected static class`
  `SystemRegistryImpl.CommandData`
  Holds parsed command data for pipeline execution.
  `static enum`
  `SystemRegistryImpl.Pipe`
  Pipe operators used to connect commands in a pipeline.
  `static class`
  `SystemRegistryImpl.UnknownCommandException`
  Exception thrown when a command is not recognized.

  ## Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry

  `org.jline.console.CommandRegistry.CommandSession`

  ## Nested classes/interfaces inherited from interface org.jline.console.SystemRegistry

  `org.jline.console.SystemRegistry.Registeries`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final org.jline.builtins.ConfigurationPath`
  `configPath`
  Configuration path for storing user-specific settings
  `protected final org.jline.reader.Parser`
  `parser`
  The parser used for command line parsing
  `protected final Supplier<Path>`
  `workDir`
  Supplier for the working directory

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SystemRegistryImpl(org.jline.reader.Parser parser, org.jline.terminal.Terminal terminal, Supplier<Path> workDir, org.jline.builtins.ConfigurationPath configPath)`
  Constructs a new SystemRegistryImpl.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCompleter(org.jline.reader.Completer completer)`
  Adds a completer to the registry.
  `void`
  `cleanUp()`
  Cleans up output streams and purges temporary data.
  `void`
  `close()`
  Persists collected command names before shutdown.
  `Map<String,String>`
  `commandAliases()`
  Returns all command aliases.
  `org.jline.console.CmdDesc`
  `commandDescription(List<String> args)`
  Returns the description for a command given its arguments.
  `org.jline.console.CmdDesc`
  `commandDescription(org.jline.console.CmdLine line)`
  Returns the description for a command line.
  `List<String>`
  `commandInfo(String command)`
  Returns the help information for a command.
  `Set<String>`
  `commandNames()`
  Returns the names of all registered commands.
  `org.jline.reader.impl.completer.SystemCompleter`
  `compileCompleters()`
  Compiles all registered completers into a system completer.
  `org.jline.reader.Completer`
  `completer()`
  Returns the completer for all registered commands and scripts.
  `org.jline.console.ConsoleEngine`
  `consoleEngine()`
  Returns the console engine, if available.
  `Object`
  `consoleOption(String name)`
  Retrieves a console option value.
  `<T> T`
  `consoleOption(String name, T defVal)`
  Retrieves a console option value with a default.
  `Object`
  `execute(String line)`
  Executes a command line, including pipes, redirection, and console statements.
  `Collection<String>`
  `getPipeNames()`
  Returns the names of all pipe operators.
  `SystemRegistryImpl`
  `groupCommandsInHelp(boolean commandGroups)`
  Sets whether commands should be grouped by registry in help output.
  `boolean`
  `hasCommand(String command)`
  Checks if a command exists.
  `void`
  `initialize(File script)`
  Initializes the system by executing a startup script.
  `Object`
  `invoke(String command, Object... args)`
  Invokes a command with the given arguments.
  `boolean`
  `isCommandAlias(String command)`
  Checks if the command is an alias.
  `boolean`
  `isCommandOrScript(String command)`
  Checks if the given string represents a command or script.
  `boolean`
  `isCommandOrScript(org.jline.reader.ParsedLine line)`
  Checks if the parsed line represents a command or script.
  `void`
  `register(String command, org.jline.console.CommandRegistry subcommandRegistry)`
  Register subcommand registry
  `void`
  `rename(SystemRegistryImpl.Pipe pipe, String name)`
  Renames a pipe operator.
  `void`
  `renameLocal(String command, String newName)`
  Renames a local command.
  `void`
  `setCommandRegistries(org.jline.console.CommandRegistry... commandRegistries)`
  Sets the command registries managed by this system registry.
  `void`
  `setConsoleOption(String name, Object value)`
  Sets a console option value.
  `void`
  `setGroupCommandsInHelp(boolean commandGroups)`
  Sets whether commands should be grouped by registry in help output.
  `void`
  `setScriptDescription(Function<org.jline.console.CmdLine,org.jline.console.CmdDesc> scriptDescription)`
  Sets the function used to describe scripts for tab completion.
  `org.jline.terminal.Terminal`
  `terminal()`
  Returns the terminal associated with this registry.
  `void`
  `trace(boolean stack, Throwable exception)`
  Reports an exception, optionally printing its full stack trace.
  `void`
  `trace(Throwable exception)`
  Reports an exception using the configured console-aware tracing strategy.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.jline.console.CommandRegistry

  `invoke, name`

- ## Field Details

  - ### parser

    protected final org.jline.reader.Parser parser
    The parser used for command line parsing

  - ### configPath

    protected final org.jline.builtins.ConfigurationPath configPath
    Configuration path for storing user-specific settings

  - ### workDir

    protected final Supplier<Path> workDir
    Supplier for the working directory

- ## Constructor Details

  - ### SystemRegistryImpl

    public SystemRegistryImpl(org.jline.reader.Parser parser, org.jline.terminal.Terminal terminal, Supplier<Path> workDir, org.jline.builtins.ConfigurationPath configPath)
    Constructs a new SystemRegistryImpl.
    Parameters:
      `parser` - the parser for command line parsing
      `terminal` - the terminal to use for input/output
      `workDir` - supplier for the working directory
      `configPath` - configuration path for user-specific settings

- ## Method Details

  - ### rename

    public void rename(SystemRegistryImpl.Pipe pipe, String name)
    Renames a pipe operator.
    Parameters:
      `pipe` - the pipe to rename
      `name` - the new name
    Throws:
      `IllegalArgumentException` - if the name is invalid or already in use

  - ### renameLocal

    public void renameLocal(String command, String newName)
    Renames a local command.
    Parameters:
      `command` - the command to rename
      `newName` - the new name for the command

  - ### getPipeNames

    public Collection<String> getPipeNames()
    Returns the names of all pipe operators.
    Specified by:
      `getPipeNames` in interface `org.jline.console.SystemRegistry`
    Returns:
      collection of pipe names

  - ### setCommandRegistries

    public void setCommandRegistries(org.jline.console.CommandRegistry... commandRegistries)
    Sets the command registries managed by this system registry.
    Specified by:
      `setCommandRegistries` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `commandRegistries` - the command registries to set

  - ### initialize

    public void initialize(File script)
    Initializes the system by executing a startup script.
    Specified by:
      `initialize` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `script` - the script file to execute

  - ### commandNames

    public Set<String> commandNames()
    Returns the names of all registered commands.
    Specified by:
      `commandNames` in interface `org.jline.console.CommandRegistry`
    Returns:
      set of command names

  - ### commandAliases

    public Map<String,String> commandAliases()
    Returns all command aliases.
    Specified by:
      `commandAliases` in interface `org.jline.console.CommandRegistry`
    Returns:
      map of aliases to command names

  - ### consoleOption

    public Object consoleOption(String name)
    Retrieves a console option value.
    Specified by:
      `consoleOption` in interface `org.jline.builtins.ConsoleOptionGetter`
    Specified by:
      `consoleOption` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `name` - the option name
    Returns:
      the option value, or `null` if not found

  - ### consoleOption

    public <T> T consoleOption(String name, T defVal)
    Retrieves a console option value with a default.
    Specified by:
      `consoleOption` in interface `org.jline.builtins.ConsoleOptionGetter`
    Specified by:
      `consoleOption` in interface `org.jline.console.SystemRegistry`
    Type Parameters:
      `T` - the option value type
    Parameters:
      `name` - the option name
      `defVal` - the default value
    Returns:
      the option value, or the default if not found

  - ### setConsoleOption

    public void setConsoleOption(String name, Object value)
    Sets a console option value.
    Specified by:
      `setConsoleOption` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `name` - the option name
      `value` - the option value

  - ### register

    public void register(String command, org.jline.console.CommandRegistry subcommandRegistry)
    Register subcommand registry
    Specified by:
      `register` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `command` - main command
      `subcommandRegistry` - subcommand registry

  - ### commandInfo

    public List<String> commandInfo(String command)
    Returns the help information for a command.
    Specified by:
      `commandInfo` in interface `org.jline.console.CommandRegistry`
    Parameters:
      `command` - the command name
    Returns:
      list of help text lines

  - ### hasCommand

    public boolean hasCommand(String command)
    Checks if a command exists.
    Specified by:
      `hasCommand` in interface `org.jline.console.CommandRegistry`
    Parameters:
      `command` - the command name
    Returns:
      `true` if the command exists, `false` otherwise

  - ### setGroupCommandsInHelp

    public void setGroupCommandsInHelp(boolean commandGroups)
    Sets whether commands should be grouped by registry in help output.
    Parameters:
      `commandGroups` - true to group commands, false otherwise

  - ### groupCommandsInHelp

    public SystemRegistryImpl groupCommandsInHelp(boolean commandGroups)
    Sets whether commands should be grouped by registry in help output.
    Parameters:
      `commandGroups` - true to group commands, false otherwise
    Returns:
      this instance for method chaining

  - ### isCommandOrScript

    public boolean isCommandOrScript(org.jline.reader.ParsedLine line)
    Checks if the parsed line represents a command or script.
    Specified by:
      `isCommandOrScript` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `line` - the parsed line to check
    Returns:
      `true` if the line is a command or script, `false` otherwise

  - ### isCommandOrScript

    public boolean isCommandOrScript(String command)
    Checks if the given string represents a command or script.
    Specified by:
      `isCommandOrScript` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `command` - the command name to check
    Returns:
      `true` if the command or script exists, `false` otherwise

  - ### addCompleter

    public void addCompleter(org.jline.reader.Completer completer)
    Adds a completer to the registry.
    Parameters:
      `completer` - the completer to add

  - ### compileCompleters

    public org.jline.reader.impl.completer.SystemCompleter compileCompleters()
    Compiles all registered completers into a system completer.
    Specified by:
      `compileCompleters` in interface `org.jline.console.CommandRegistry`
    Returns:
      the system completer
    Throws:
      `IllegalStateException` - always; use `completer()` instead

  - ### completer

    public org.jline.reader.Completer completer()
    Returns the completer for all registered commands and scripts.
    Specified by:
      `completer` in interface `org.jline.console.SystemRegistry`
    Returns:
      the completer instance

  - ### commandDescription

    public org.jline.console.CmdDesc commandDescription(List<String> args)
    Returns the description for a command given its arguments.
    Specified by:
      `commandDescription` in interface `org.jline.console.CommandRegistry`
    Parameters:
      `args` - the command arguments
    Returns:
      the command description

  - ### setScriptDescription

    public void setScriptDescription(Function<org.jline.console.CmdLine,org.jline.console.CmdDesc> scriptDescription)
    Sets the function used to describe scripts for tab completion.
    Parameters:
      `scriptDescription` - the script description function

  - ### commandDescription

    public org.jline.console.CmdDesc commandDescription(org.jline.console.CmdLine line)
    Returns the description for a command line.
    Specified by:
      `commandDescription` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `line` - the command line
    Returns:
      the command description

  - ### invoke

    public Object invoke(String command, Object... args) throws Exception
    Invokes a command with the given arguments.
    Specified by:
      `invoke` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `command` - the command name
      `args` - the command arguments
    Returns:
      the result of command execution
    Throws:
      `Exception` - if command execution fails

  - ### terminal

    public org.jline.terminal.Terminal terminal()
    Returns the terminal associated with this registry.
    Specified by:
      `terminal` in interface `org.jline.console.SystemRegistry`
    Returns:
      the terminal

  - ### isCommandAlias

    public boolean isCommandAlias(String command)
    Checks if the command is an alias.
    Specified by:
      `isCommandAlias` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `command` - the command name
    Returns:
      `true` if the command is an alias, `false` otherwise

  - ### execute

    public Object execute(String line) throws Exception
    Executes a command line, including pipes, redirection, and console statements.
    Specified by:
      `execute` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `line` - command line to execute
    Returns:
      command result, if any
    Throws:
      `Exception` - if command execution fails

  - ### cleanUp

    public void cleanUp()
    Cleans up output streams and purges temporary data.
    Specified by:
      `cleanUp` in interface `org.jline.console.SystemRegistry`

  - ### trace

    public void trace(Throwable exception)
    Reports an exception using the configured console-aware tracing strategy.
    Specified by:
      `trace` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `exception` - exception to report

  - ### trace

    public void trace(boolean stack, Throwable exception)
    Reports an exception, optionally printing its full stack trace.
    Specified by:
      `trace` in interface `org.jline.console.SystemRegistry`
    Parameters:
      `stack` - whether to print the full stack trace
      `exception` - exception to report

  - ### close

    public void close()
    Persists collected command names before shutdown.
    Specified by:
      `close` in interface `org.jline.console.SystemRegistry`

  - ### consoleEngine

    public org.jline.console.ConsoleEngine consoleEngine()
    Returns the console engine, if available.
    Returns:
      the console engine, or null if not configured