Package org.jline.console.impl
Class SystemRegistryImpl
java.lang.Object
org.jline.console.impl.SystemRegistryImpl
- All Implemented Interfaces:
ConsoleOptionGetter
,CommandRegistry
,SystemRegistry
Aggregate command registries.
- Author:
- Matti Rinta-Nikkola
-
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSystemRegistryImpl
(Parser parser, Terminal terminal, Supplier<Path> workDir, ConfigurationPath configPath) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCompleter
(Completer completer) void
cleanUp()
Delete temporary console variables and reset output streamsvoid
close()
Orderly close SystemRegistry.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 command, method or syntax description 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.Returns aSystemCompleter
that can provide detailed completion information for all registered commands.Returns command completer that includes also console variable and script completion.consoleOption
(String name) Return console option value<T> T
consoleOption
(String name, T defVal) Return console option valueExecute a command, script or evaluate scriptEngine statementgroupCommandsInHelp
(boolean commandGroups) boolean
hasCommand
(String command) Returns whether a command with the specified name is known to this registry.void
initialize
(File script) Initialize consoleEngine environment by executing console scriptExecute command with argumentsboolean
isCommandAlias
(String command) Returns whether alias is known command alias.boolean
isCommandOrScript
(String command) Returns whether command is known to this registry.boolean
isCommandOrScript
(ParsedLine line) Returns whether a line contains command/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) Set command registriesvoid
setConsoleOption
(String name, Object value) Set console option valuevoid
setGroupCommandsInHelp
(boolean commandGroups) void
setScriptDescription
(Function<CmdLine, CmdDesc> scriptDescription) terminal()
void
Print exception on terminalvoid
Print exception on terminalMethods 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
-
configPath
-
workDir
-
-
Constructor Details
-
SystemRegistryImpl
public SystemRegistryImpl(Parser parser, Terminal terminal, Supplier<Path> workDir, ConfigurationPath configPath)
-
-
Method Details
-
rename
-
getPipeNames
- Specified by:
getPipeNames
in interfaceSystemRegistry
- Returns:
- pipe names defined in systemRegistry
-
setCommandRegistries
Description copied from interface:SystemRegistry
Set command registries- Specified by:
setCommandRegistries
in interfaceSystemRegistry
- Parameters:
commandRegistries
- command registries used by the application
-
initialize
Description copied from interface:SystemRegistry
Initialize consoleEngine environment by executing console script- Specified by:
initialize
in interfaceSystemRegistry
- Parameters:
script
- initialization script
-
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
Return console option value- Specified by:
consoleOption
in interfaceConsoleOptionGetter
- Specified by:
consoleOption
in interfaceSystemRegistry
- Parameters:
name
- the option name- Returns:
- option value
-
consoleOption
Description copied from interface:SystemRegistry
Return console option value- Specified by:
consoleOption
in interfaceConsoleOptionGetter
- Specified by:
consoleOption
in interfaceSystemRegistry
- Type Parameters:
T
- option type- Parameters:
name
- the option namedefVal
- value to return if console option does not exists- Returns:
- option value
-
setConsoleOption
Description copied from interface:SystemRegistry
Set console option value- Specified by:
setConsoleOption
in interfaceSystemRegistry
- Parameters:
name
- the option namevalue
- value to assign console 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
Description copied from interface:SystemRegistry
Returns whether a line contains command/script that is known to this registry.- Specified by:
isCommandOrScript
in interfaceSystemRegistry
- Parameters:
line
- the parsed command line to test- Returns:
- true if the specified line has a command registered
-
isCommandOrScript
Description copied from interface:SystemRegistry
Returns whether command is known to this registry.- Specified by:
isCommandOrScript
in interfaceSystemRegistry
- Parameters:
command
- the command to test- Returns:
- true if the specified command is known
-
addCompleter
-
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
Description copied from interface:SystemRegistry
Returns command completer that includes also console variable and script completion.- Specified by:
completer
in interfaceSystemRegistry
- Returns:
- command completer
-
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 command, method or syntax description for use in the JLine Widgets framework.- Specified by:
commandDescription
in interfaceSystemRegistry
- Parameters:
line
- command line whose description to return- Returns:
- command description for JLine TailTipWidgets to be displayed in the terminal status bar.
-
invoke
Description copied from interface:SystemRegistry
Execute command with arguments- Specified by:
invoke
in interfaceSystemRegistry
- Parameters:
command
- command to be executedargs
- arguments of the command- Returns:
- command execution result
- Throws:
Exception
- in case of error
-
terminal
- Specified by:
terminal
in interfaceSystemRegistry
- Returns:
- terminal
-
isCommandAlias
Description copied from interface:SystemRegistry
Returns whether alias is known command alias.- Specified by:
isCommandAlias
in interfaceSystemRegistry
- Parameters:
command
- the alias to test- Returns:
- true if the alias is known command alias
-
execute
Description copied from interface:SystemRegistry
Execute a command, script or evaluate scriptEngine statement- Specified by:
execute
in interfaceSystemRegistry
- 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 interfaceSystemRegistry
-
trace
Description copied from interface:SystemRegistry
Print exception on terminal- Specified by:
trace
in interfaceSystemRegistry
- Parameters:
exception
- exception to print on terminal
-
trace
Description copied from interface:SystemRegistry
Print exception on terminal- Specified by:
trace
in interfaceSystemRegistry
- Parameters:
stack
- print stack trace if stack true otherwise messageexception
- exception to be printed
-
close
public void close()Description copied from interface:SystemRegistry
Orderly close SystemRegistry.- Specified by:
close
in interfaceSystemRegistry
-
consoleEngine
-