Class SystemRegistryImpl
- All Implemented Interfaces:
org.jline.builtins.ConsoleOptionGetter
,CommandRegistry
,SystemRegistry
- Direct Known Subclasses:
SimpleSystemRegistryImpl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
static enum
static class
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSession
Nested classes/interfaces inherited from interface org.jline.console.SystemRegistry
SystemRegistry.Registeries
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.jline.builtins.ConfigurationPath
protected final org.jline.reader.Parser
-
Constructor Summary
ConstructorsConstructorDescriptionSystemRegistryImpl
(org.jline.reader.Parser parser, org.jline.terminal.Terminal terminal, Supplier<Path> workDir, org.jline.builtins.ConfigurationPath configPath) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCompleter
(org.jline.reader.Completer completer) void
cleanUp()
Deletes temporary console variables and resets output streams.void
close()
Orderly closes this system registry.Returns a map of alias-to-command names known by this registry.commandDescription
(List<String> args) Returns a command description for use in the JLine Widgets framework.commandDescription
(CmdLine line) Returns a description for a command, method, or syntax for use in the JLine Widgets framework.commandInfo
(String command) Returns a short info about command known by this registry.Returns the command names known by this registry.org.jline.reader.impl.completer.SystemCompleter
Returns aSystemCompleter
that can provide detailed completion information for all registered commands.org.jline.reader.Completer
Returns a command completer that includes console variable and script completion.consoleOption
(String name) Returns the value of a console option.<T> T
consoleOption
(String name, T defVal) Returns the value of a console option with a default value if the option doesn't exist.Executes a command, script, or evaluates a script engine statement.Returns the names of all pipes defined in this system registry.groupCommandsInHelp
(boolean commandGroups) boolean
hasCommand
(String command) Returns whether a command with the specified name is known to this registry.void
initialize
(File script) Initializes the console engine environment by executing a console script.Executes a command with the specified arguments.boolean
isCommandAlias
(String command) Checks if an alias is a known command alias.boolean
isCommandOrScript
(String command) Checks if a command or script is known to this registry.boolean
isCommandOrScript
(org.jline.reader.ParsedLine line) Checks if a parsed line contains a command or script that is known to this registry.void
register
(String command, CommandRegistry subcommandRegistry) Register subcommand registryvoid
rename
(SystemRegistryImpl.Pipe pipe, String name) void
setCommandRegistries
(CommandRegistry... commandRegistries) Sets the command registries to be used by this system registry.void
setConsoleOption
(String name, Object value) Sets the value of a console option.void
setGroupCommandsInHelp
(boolean commandGroups) void
setScriptDescription
(Function<CmdLine, CmdDesc> scriptDescription) org.jline.terminal.Terminal
terminal()
Returns the terminal associated with this system registry.void
Prints an exception on the terminal with control over stack trace display.void
Prints an exception on the terminal.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 -
configPath
protected final org.jline.builtins.ConfigurationPath configPath -
workDir
-
-
Constructor Details
-
SystemRegistryImpl
-
-
Method Details
-
rename
-
getPipeNames
Description copied from interface:SystemRegistry
Returns the names of all pipes defined in this system registry.This method retrieves the names of all pipes that have been defined in this system registry. Pipes are used to connect the output of one command to the input of another.
- Specified by:
getPipeNames
in interfaceSystemRegistry
- Returns:
- a collection of pipe names defined in this system registry
-
setCommandRegistries
Description copied from interface:SystemRegistry
Sets the command registries to be used by this system registry.This method configures the command registries that will be aggregated by this system registry. Commands from all of these registries will be available for execution through this system registry.
- Specified by:
setCommandRegistries
in interfaceSystemRegistry
- Parameters:
commandRegistries
- the command registries to be used by the application
-
initialize
Description copied from interface:SystemRegistry
Initializes the console engine environment by executing a console script.This method executes the specified script to initialize the console engine environment. The script can set up variables, aliases, and other configuration needed for the console application.
- Specified by:
initialize
in interfaceSystemRegistry
- Parameters:
script
- the initialization script to execute
-
commandNames
Description copied from interface:CommandRegistry
Returns the command names known by this registry.- Specified by:
commandNames
in interfaceCommandRegistry
- Returns:
- the set of known command names, excluding aliases
-
commandAliases
Description copied from interface:CommandRegistry
Returns a map of alias-to-command names known by this registry.- Specified by:
commandAliases
in interfaceCommandRegistry
- Returns:
- a map with alias keys and command name values
-
consoleOption
Description copied from interface:SystemRegistry
Returns the value of a console option.This method retrieves the value of the console option with the specified name. Console options are used to configure the behavior of the console and its components.
- Specified by:
consoleOption
in interfaceorg.jline.builtins.ConsoleOptionGetter
- Specified by:
consoleOption
in interfaceSystemRegistry
- Parameters:
name
- the name of the option to retrieve- Returns:
- the value of the option, or null if the option doesn't exist
-
consoleOption
Description copied from interface:SystemRegistry
Returns the value of a console option with a default value if the option doesn't exist.This method retrieves the value of the console option with the specified name, returning a default value if the option doesn't exist. Console options are used to configure the behavior of the console and its components.
- Specified by:
consoleOption
in interfaceorg.jline.builtins.ConsoleOptionGetter
- Specified by:
consoleOption
in interfaceSystemRegistry
- Type Parameters:
T
- the type of the option value- Parameters:
name
- the name of the option to retrievedefVal
- the default value to return if the option doesn't exist- Returns:
- the value of the option, or the default value if the option doesn't exist
-
setConsoleOption
Description copied from interface:SystemRegistry
Sets the value of a console option.This method sets the value of the console option with the specified name. Console options are used to configure the behavior of the console and its components.
- Specified by:
setConsoleOption
in interfaceSystemRegistry
- Parameters:
name
- the name of the option to setvalue
- the value to assign to the option
-
register
Register subcommand registry- Specified by:
register
in interfaceSystemRegistry
- Parameters:
command
- main commandsubcommandRegistry
- subcommand registry
-
commandInfo
Description copied from interface:CommandRegistry
Returns a short info about command known by this registry.- Specified by:
commandInfo
in interfaceCommandRegistry
- Parameters:
command
- the command name- Returns:
- a short info about command
-
hasCommand
Description copied from interface:CommandRegistry
Returns whether a command with the specified name is known to this registry.- Specified by:
hasCommand
in interfaceCommandRegistry
- Parameters:
command
- the command name to test- Returns:
- true if the specified command is registered
-
setGroupCommandsInHelp
public void setGroupCommandsInHelp(boolean commandGroups) -
groupCommandsInHelp
-
isCommandOrScript
public boolean isCommandOrScript(org.jline.reader.ParsedLine line) Description copied from interface:SystemRegistry
Checks if a parsed line contains a command or script that is known to this registry.This method determines whether the specified parsed command line contains a command or script that is known to this registry. This can be used to determine whether the line can be executed by this registry.
- Specified by:
isCommandOrScript
in interfaceSystemRegistry
- Parameters:
line
- the parsed command line to test- Returns:
- true if the specified line contains a command or script that is known to this registry, false otherwise
-
isCommandOrScript
Description copied from interface:SystemRegistry
Checks if a command or script is known to this registry.This method determines whether the specified command or script is known to this registry. This can be used to determine whether the command or script can be executed by this registry.
- Specified by:
isCommandOrScript
in interfaceSystemRegistry
- Parameters:
command
- the command or script name to test- Returns:
- true if the specified command or script is known to this registry, false otherwise
-
addCompleter
public void addCompleter(org.jline.reader.Completer completer) -
compileCompleters
public org.jline.reader.impl.completer.SystemCompleter compileCompleters()Description copied from interface:CommandRegistry
Returns aSystemCompleter
that can provide detailed completion information for all registered commands.- Specified by:
compileCompleters
in interfaceCommandRegistry
- Returns:
- a SystemCompleter that can provide command completion for all registered commands
-
completer
public org.jline.reader.Completer completer()Description copied from interface:SystemRegistry
Returns a command completer that includes console variable and script completion.This method creates a completer that can provide completion for commands, console variables, and scripts. The completer can be used for tab completion in the console.
- Specified by:
completer
in interfaceSystemRegistry
- Returns:
- a completer for commands, console variables, and scripts
-
commandDescription
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 interfaceCommandRegistry
- Parameters:
args
- command (args[0]) and its arguments- Returns:
- command description for JLine TailTipWidgets to be displayed in the terminal status bar.
-
setScriptDescription
-
commandDescription
Description copied from interface:SystemRegistry
Returns a description for a command, method, or syntax for use in the JLine Widgets framework.This method generates a description for the specified command line, which can be displayed in the terminal status bar by JLine TailTipWidgets. The description includes information about the command's arguments, options, and usage.
- Specified by:
commandDescription
in interfaceSystemRegistry
- Parameters:
line
- the command line whose description to return- Returns:
- a command description for JLine TailTipWidgets to be displayed in the terminal status bar
-
invoke
Description copied from interface:SystemRegistry
Executes a command with the specified arguments.This method executes the specified command with the specified arguments. The command is looked up in the command registries associated with this system registry.
- Specified by:
invoke
in interfaceSystemRegistry
- Parameters:
command
- the command to be executedargs
- the arguments to pass to the command- Returns:
- the result of executing the command
- Throws:
Exception
- if an error occurs during execution
-
terminal
public org.jline.terminal.Terminal terminal()Description copied from interface:SystemRegistry
Returns the terminal associated with this system registry.This method retrieves the terminal that is used by this system registry for input and output operations.
- Specified by:
terminal
in interfaceSystemRegistry
- Returns:
- the terminal associated with this system registry
-
isCommandAlias
Description copied from interface:SystemRegistry
Checks if an alias is a known command alias.This method determines whether the specified alias is a known command alias. Command aliases are alternative names for commands that can be used to invoke them.
- Specified by:
isCommandAlias
in interfaceSystemRegistry
- Parameters:
command
- the alias to test- Returns:
- true if the specified alias is a known command alias, false otherwise
-
execute
Description copied from interface:SystemRegistry
Executes a command, script, or evaluates a script engine statement.This method parses and executes the specified command line. If the line contains a known command, it will be executed. If it contains a script name, the script will be executed. Otherwise, the line will be evaluated as a script engine statement.
- Specified by:
execute
in interfaceSystemRegistry
- Parameters:
line
- the command line to be executed- Returns:
- the result of executing the command line
- Throws:
Exception
- if an error occurs during execution
-
cleanUp
public void cleanUp()Description copied from interface:SystemRegistry
Deletes temporary console variables and resets output streams.This method cleans up temporary console variables and resets output streams to their default state. It should be called after command execution to ensure that temporary variables and redirected output streams don't affect subsequent commands.
- Specified by:
cleanUp
in interfaceSystemRegistry
-
trace
Description copied from interface:SystemRegistry
Prints an exception on the terminal.This method prints the specified exception on the terminal, including its message and stack trace. This is a convenience method that calls
SystemRegistry.trace(boolean, Throwable)
with stack=true.- Specified by:
trace
in interfaceSystemRegistry
- Parameters:
exception
- the exception to print on the terminal
-
trace
Description copied from interface:SystemRegistry
Prints an exception on the terminal with control over stack trace display.This method prints the specified exception on the terminal. If stack is true, the full stack trace will be printed. Otherwise, only the exception message will be printed.
- Specified by:
trace
in interfaceSystemRegistry
- Parameters:
stack
- whether to print the full stack trace (true) or just the message (false)exception
- the exception to be printed
-
close
public void close()Description copied from interface:SystemRegistry
Orderly closes this system registry.This method performs an orderly shutdown of this system registry, releasing any resources it holds and performing any necessary cleanup operations. It should be called when the system registry is no longer needed.
- Specified by:
close
in interfaceSystemRegistry
-
consoleEngine
-