Package org.jline.console.impl
Class SystemRegistryImpl
java.lang.Object
org.jline.console.impl.SystemRegistryImpl
- All Implemented Interfaces:
ConsoleOptionGetter
,CommandRegistry
,SystemRegistry
Aggregate command registries.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
protected static class
private static class
private class
static enum
private static class
private static class
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 TypeFieldDescriptionprivate static final Class<?>[]
private final Map<String,
CommandMethods> private boolean
private CommandRegistry[]
protected final ConfigurationPath
private Integer
private final AggregateCompleter
private final SystemCompleter
private Exception
private final SystemRegistryImpl.CommandOutputStream
protected final Parser
private final Map<SystemRegistryImpl.Pipe,
String> private SystemRegistryImpl.ScriptStore
private final Map<String,
CommandRegistry> -
Constructor Summary
ConstructorsConstructorDescriptionSystemRegistryImpl
(Parser parser, Terminal terminal, Supplier<Path> workDir, ConfigurationPath configPath) -
Method Summary
Modifier and TypeMethodDescriptionprivate SystemCompleter
void
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.private CmdDesc
commandDescription
(CommandRegistry subreg) commandInfo
(String command) Returns a short info about command known by this registry.Returns the command names known by this registry.private List<Completers.OptDesc>
commandOptions
(String command) private CommandRegistry.CommandSession
private List<SystemRegistryImpl.CommandData>
compileCommandLine
(String commandLine) 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 valueprivate String
doCommandInfo
(List<String> info) emptyCompleter
(String command) Execute a command, script or evaluate scriptEngine statementprivate Object
private Object
exit
(CommandInput input) exitCompleter
(String command) private String
groupCommandsInHelp
(boolean commandGroups) boolean
hasCommand
(String command) Returns whether a command with the specified name is known to this registry.private Object
help
(CommandInput input) helpCompleter
(String command) private void
void
initialize
(File script) Initialize consoleEngine environment by executing console scriptExecute command with argumentsprivate boolean
isBuiltinRegistry
(CommandRegistry registry) boolean
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.private boolean
isInTopics
(List<String> args, String name) private boolean
isLocalCommand
(String command) private CmdDesc
localCommandDescription
(String command) localCommandInfo
(String command) private Object
localExecute
(String command, Object[] args) private Options
parseOptions
(String[] usage, Object[] args) private ConsoleEngine.ExecutionResult
postProcess
(SystemRegistryImpl.CommandData cmd, boolean statement, ConsoleEngine consoleEngine, Object result) private void
printCommandInfo
(String command, String info, int max) private void
printCommands
(Collection<String> commands, int max) private void
printHeader
(String header) private File
redirectFile
(String name) void
register
(String command, CommandRegistry subcommandRegistry) Register subcommand registryprivate void
registryHelp
(CommandRegistry registry) private int
registryId
(String command) void
rename
(SystemRegistryImpl.Pipe pipe, String name) private String
replaceCommandAlias
(String variable, String command, String rawLine) private String
replacePipeAlias
(SystemRegistryImpl.ArgsParser ap, String pipeAlias, List<String> args, Map<String, List<String>> customPipes) private void
replacePipeAliases
(ConsoleEngine consoleEngine, Map<String, List<String>> customPipes, SystemRegistryImpl.ArgsParser ap) 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) private Object
subcommand
(CommandInput input) terminal()
void
Print exception on terminalvoid
Print exception on terminalprivate void
trace
(SystemRegistryImpl.CommandData commandData) 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
-
BUILTIN_REGISTRIES
-
commandRegistries
-
consoleId
-
parser
-
configPath
-
workDir
-
subcommands
-
pipeName
-
commandExecute
-
commandInfos
-
exception
-
outputStream
-
scriptStore
-
names
-
customSystemCompleter
-
customAggregateCompleter
-
commandGroups
private boolean commandGroups -
scriptDescription
-
-
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
-
localCommandNames
-
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
-
localCommandInfo
-
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
-
isLocalCommand
-
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
-
_compileCompleters
-
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
-
localCommandDescription
-
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.
-
commandDescription
-
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
-
localExecute
- Throws:
Exception
-
terminal
- Specified by:
terminal
in interfaceSystemRegistry
- Returns:
- terminal
-
commandSession
-
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
-
replaceCommandAlias
-
replacePipeAlias
-
replacePipeAliases
private void replacePipeAliases(ConsoleEngine consoleEngine, Map<String, List<String>> customPipes, SystemRegistryImpl.ArgsParser ap) -
compileCommandLine
-
redirectFile
-
flipArgument
-
execute
- Throws:
Exception
-
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
-
postProcess
private ConsoleEngine.ExecutionResult postProcess(SystemRegistryImpl.CommandData cmd, boolean statement, ConsoleEngine consoleEngine, Object result) -
cleanUp
public void cleanUp()Description copied from interface:SystemRegistry
Delete temporary console variables and reset output streams- Specified by:
cleanUp
in interfaceSystemRegistry
-
trace
-
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
-
isBuiltinRegistry
-
printHeader
-
printCommandInfo
-
printCommands
-
doCommandInfo
-
isInTopics
-
parseOptions
- Throws:
Options.HelpException
-
help
-
helpTopic
-
exit
-
registryHelp
- Throws:
Exception
-
subcommand
-
commandOptions
-
registryNames
-
emptyCompleter
-
helpCompleter
-
exitCompleter
-
registryId
-