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 classprotected static classprivate static classprivate classstatic enumprivate static classprivate static classstatic classNested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSessionNested 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 booleanprivate CommandRegistry[]protected final ConfigurationPathprivate Integerprivate final AggregateCompleterprivate final SystemCompleterprivate Exceptionprivate final SystemRegistryImpl.CommandOutputStreamprotected final Parserprivate final Map<SystemRegistryImpl.Pipe, String> private SystemRegistryImpl.ScriptStoreprivate final Map<String, CommandRegistry> -
Constructor Summary
ConstructorsConstructorDescriptionSystemRegistryImpl(Parser parser, Terminal terminal, Supplier<Path> workDir, ConfigurationPath configPath) -
Method Summary
Modifier and TypeMethodDescriptionprivate SystemCompletervoidaddCompleter(Completer completer) voidcleanUp()Delete temporary console variables and reset output streamsvoidclose()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 CmdDesccommandDescription(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.CommandSessionprivate List<SystemRegistryImpl.CommandData> compileCommandLine(String commandLine) Returns aSystemCompleterthat 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> TconsoleOption(String name, T defVal) Return console option valueprivate StringdoCommandInfo(List<String> info) emptyCompleter(String command) Execute a command, script or evaluate scriptEngine statementprivate Objectprivate Objectexit(CommandInput input) exitCompleter(String command) private StringgroupCommandsInHelp(boolean commandGroups) booleanhasCommand(String command) Returns whether a command with the specified name is known to this registry.private Objecthelp(CommandInput input) helpCompleter(String command) private voidvoidinitialize(File script) Initialize consoleEngine environment by executing console scriptExecute command with argumentsprivate booleanisBuiltinRegistry(CommandRegistry registry) booleanisCommandAlias(String command) Returns whether alias is known command alias.booleanisCommandOrScript(String command) Returns whether command is known to this registry.booleanisCommandOrScript(ParsedLine line) Returns whether a line contains command/script that is known to this registry.private booleanisInTopics(List<String> args, String name) private booleanisLocalCommand(String command) private CmdDesclocalCommandDescription(String command) localCommandInfo(String command) private ObjectlocalExecute(String command, Object[] args) private OptionsparseOptions(String[] usage, Object[] args) private ConsoleEngine.ExecutionResultpostProcess(SystemRegistryImpl.CommandData cmd, boolean statement, ConsoleEngine consoleEngine, Object result) private voidprintCommandInfo(String command, String info, int max) private voidprintCommands(Collection<String> commands, int max) private voidprintHeader(String header) private FileredirectFile(String name) voidregister(String command, CommandRegistry subcommandRegistry) Register subcommand registryprivate voidregistryHelp(CommandRegistry registry) private intregistryId(String command) voidrename(SystemRegistryImpl.Pipe pipe, String name) private StringreplaceCommandAlias(String variable, String command, String rawLine) private StringreplacePipeAlias(SystemRegistryImpl.ArgsParser ap, String pipeAlias, List<String> args, Map<String, List<String>> customPipes) private voidreplacePipeAliases(ConsoleEngine consoleEngine, Map<String, List<String>> customPipes, SystemRegistryImpl.ArgsParser ap) voidsetCommandRegistries(CommandRegistry... commandRegistries) Set command registriesvoidsetConsoleOption(String name, Object value) Set console option valuevoidsetGroupCommandsInHelp(boolean commandGroups) voidsetScriptDescription(Function<CmdLine, CmdDesc> scriptDescription) private Objectsubcommand(CommandInput input) terminal()voidPrint exception on terminalvoidPrint exception on terminalprivate voidtrace(SystemRegistryImpl.CommandData commandData) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getPipeNamesin interfaceSystemRegistry- Returns:
- pipe names defined in systemRegistry
-
setCommandRegistries
Description copied from interface:SystemRegistrySet command registries- Specified by:
setCommandRegistriesin interfaceSystemRegistry- Parameters:
commandRegistries- command registries used by the application
-
initialize
Description copied from interface:SystemRegistryInitialize consoleEngine environment by executing console script- Specified by:
initializein interfaceSystemRegistry- Parameters:
script- initialization script
-
commandNames
Description copied from interface:CommandRegistryReturns the command names known by this registry.- Specified by:
commandNamesin interfaceCommandRegistry- Returns:
- the set of known command names, excluding aliases
-
localCommandNames
-
commandAliases
Description copied from interface:CommandRegistryReturns a map of alias-to-command names known by this registry.- Specified by:
commandAliasesin interfaceCommandRegistry- Returns:
- a map with alias keys and command name values
-
consoleOption
Description copied from interface:SystemRegistryReturn console option value- Specified by:
consoleOptionin interfaceConsoleOptionGetter- Specified by:
consoleOptionin interfaceSystemRegistry- Parameters:
name- the option name- Returns:
- option value
-
consoleOption
Description copied from interface:SystemRegistryReturn console option value- Specified by:
consoleOptionin interfaceConsoleOptionGetter- Specified by:
consoleOptionin 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:SystemRegistrySet console option value- Specified by:
setConsoleOptionin interfaceSystemRegistry- Parameters:
name- the option namevalue- value to assign console option
-
register
Register subcommand registry- Specified by:
registerin interfaceSystemRegistry- Parameters:
command- main commandsubcommandRegistry- subcommand registry
-
localCommandInfo
-
commandInfo
Description copied from interface:CommandRegistryReturns a short info about command known by this registry.- Specified by:
commandInfoin interfaceCommandRegistry- Parameters:
command- the command name- Returns:
- a short info about command
-
hasCommand
Description copied from interface:CommandRegistryReturns whether a command with the specified name is known to this registry.- Specified by:
hasCommandin 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:SystemRegistryReturns whether a line contains command/script that is known to this registry.- Specified by:
isCommandOrScriptin interfaceSystemRegistry- Parameters:
line- the parsed command line to test- Returns:
- true if the specified line has a command registered
-
isCommandOrScript
Description copied from interface:SystemRegistryReturns whether command is known to this registry.- Specified by:
isCommandOrScriptin interfaceSystemRegistry- Parameters:
command- the command to test- Returns:
- true if the specified command is known
-
addCompleter
-
compileCompleters
Description copied from interface:CommandRegistryReturns aSystemCompleterthat can provide detailed completion information for all registered commands.- Specified by:
compileCompletersin interfaceCommandRegistry- Returns:
- a SystemCompleter that can provide command completion for all registered commands
-
_compileCompleters
-
completer
Description copied from interface:SystemRegistryReturns command completer that includes also console variable and script completion.- Specified by:
completerin interfaceSystemRegistry- Returns:
- command completer
-
localCommandDescription
-
commandDescription
Description copied from interface:CommandRegistryReturns a command description for use in the JLine Widgets framework. Default method must be overridden to return sub command descriptions.- Specified by:
commandDescriptionin 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:SystemRegistryReturns a command, method or syntax description for use in the JLine Widgets framework.- Specified by:
commandDescriptionin 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:SystemRegistryExecute command with arguments- Specified by:
invokein 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:
terminalin interfaceSystemRegistry- Returns:
- terminal
-
commandSession
-
isCommandAlias
Description copied from interface:SystemRegistryReturns whether alias is known command alias.- Specified by:
isCommandAliasin 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:SystemRegistryExecute a command, script or evaluate scriptEngine statement- Specified by:
executein 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:SystemRegistryDelete temporary console variables and reset output streams- Specified by:
cleanUpin interfaceSystemRegistry
-
trace
-
trace
Description copied from interface:SystemRegistryPrint exception on terminal- Specified by:
tracein interfaceSystemRegistry- Parameters:
exception- exception to print on terminal
-
trace
Description copied from interface:SystemRegistryPrint exception on terminal- Specified by:
tracein interfaceSystemRegistry- Parameters:
stack- print stack trace if stack true otherwise messageexception- exception to be printed
-
close
public void close()Description copied from interface:SystemRegistryOrderly close SystemRegistry.- Specified by:
closein 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
-