- java.lang.Object
-
- org.jline.console.impl.SystemRegistryImpl
-
- All Implemented Interfaces:
ConsoleOptionGetter,CommandRegistry,SystemRegistry
public class SystemRegistryImpl extends Object implements SystemRegistry
Aggregate command registries.- Author:
- Matti Rinta-Nikkola
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSystemRegistryImpl.CommandDatastatic classSystemRegistryImpl.Pipestatic classSystemRegistryImpl.UnknownCommandException-
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 Modifier and Type Field Description protected ConfigurationPathconfigPathprotected Parserparserprotected Supplier<Path>workDir
-
Constructor Summary
Constructors Constructor Description SystemRegistryImpl(Parser parser, Terminal terminal, Supplier<Path> workDir, ConfigurationPath configPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCompleter(Completer completer)voidcleanUp()Delete temporary console variables and reset output streamsvoidclose()Orderly close SystemRegistry.Map<String,String>commandAliases()Returns a map of alias-to-command names known by this registry.CmdDesccommandDescription(List<String> args)Returns a command description for use in the JLine Widgets framework.CmdDesccommandDescription(CmdLine line)Returns a command, method or syntax description for use in the JLine Widgets framework.List<String>commandInfo(String command)Returns a short info about command known by this registry.Set<String>commandNames()Returns the command names known by this registry.SystemCompletercompileCompleters()Returns aSystemCompleterthat can provide detailed completion information for all registered commands.Completercompleter()Returns command completer that includes also console variable and script completion.ConsoleEngineconsoleEngine()ObjectconsoleOption(String name)Return console option valueObjectexecute(String line)Execute a command, script or evaluate scriptEngine statementCollection<String>getPipeNames()SystemRegistryImplgroupCommandsInHelp(boolean commandGroups)booleanhasCommand(String command)Returns whether a command with the specified name is known to this registry.voidinitialize(File script)Initialize consoleEngine environment by executing console scriptObjectinvoke(String command, Object... args)Execute command with argumentsbooleanisCommandAlias(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.voidregister(String command, CommandRegistry subcommandRegistry)Register subcommand registryvoidrename(SystemRegistryImpl.Pipe pipe, String name)voidsetCommandRegistries(CommandRegistry... commandRegistries)Set command registriesvoidsetGroupCommandsInHelp(boolean commandGroups)voidsetScriptDescription(Function<CmdLine,CmdDesc> scriptDescription)Terminalterminal()voidtrace(boolean stack, Throwable exception)Print exception on terminalvoidtrace(Throwable exception)Print exception on 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 Detail
-
parser
protected final Parser parser
-
configPath
protected final ConfigurationPath configPath
-
-
Constructor Detail
-
SystemRegistryImpl
public SystemRegistryImpl(Parser parser, Terminal terminal, Supplier<Path> workDir, ConfigurationPath configPath)
-
-
Method Detail
-
rename
public void rename(SystemRegistryImpl.Pipe pipe, String name)
-
getPipeNames
public Collection<String> getPipeNames()
- Specified by:
getPipeNamesin interfaceSystemRegistry- Returns:
- pipe names defined in systemRegistry
-
setCommandRegistries
public void setCommandRegistries(CommandRegistry... commandRegistries)
Description copied from interface:SystemRegistrySet command registries- Specified by:
setCommandRegistriesin interfaceSystemRegistry- Parameters:
commandRegistries- command registries used by the application
-
initialize
public void initialize(File script)
Description copied from interface:SystemRegistryInitialize consoleEngine environment by executing console script- Specified by:
initializein interfaceSystemRegistry- Parameters:
script- initialization script
-
commandNames
public Set<String> 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
-
commandAliases
public Map<String,String> 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
public Object consoleOption(String name)
Description copied from interface:SystemRegistryReturn console option value- Specified by:
consoleOptionin interfaceConsoleOptionGetter- Specified by:
consoleOptionin interfaceSystemRegistry- Parameters:
name- the option name- Returns:
- option value
-
register
public void register(String command, CommandRegistry subcommandRegistry)
Register subcommand registry- Specified by:
registerin interfaceSystemRegistry- Parameters:
command- main commandsubcommandRegistry- subcommand registry
-
commandInfo
public List<String> commandInfo(String command)
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
public boolean hasCommand(String command)
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
public SystemRegistryImpl groupCommandsInHelp(boolean commandGroups)
-
isCommandOrScript
public boolean isCommandOrScript(ParsedLine line)
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
public boolean isCommandOrScript(String command)
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
public void addCompleter(Completer completer)
-
compileCompleters
public SystemCompleter 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
-
completer
public Completer completer()
Description copied from interface:SystemRegistryReturns command completer that includes also console variable and script completion.- Specified by:
completerin interfaceSystemRegistry- Returns:
- command completer
-
commandDescription
public CmdDesc commandDescription(List<String> args)
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.
-
setScriptDescription
public void setScriptDescription(Function<CmdLine,CmdDesc> scriptDescription)
-
commandDescription
public CmdDesc commandDescription(CmdLine line)
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
public Object invoke(String command, Object... args) throws Exception
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
-
terminal
public Terminal terminal()
- Specified by:
terminalin interfaceSystemRegistry- Returns:
- terminal
-
isCommandAlias
public boolean isCommandAlias(String command)
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
-
execute
public Object execute(String line) throws Exception
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
-
cleanUp
public void cleanUp()
Description copied from interface:SystemRegistryDelete temporary console variables and reset output streams- Specified by:
cleanUpin interfaceSystemRegistry
-
trace
public void trace(Throwable exception)
Description copied from interface:SystemRegistryPrint exception on terminal- Specified by:
tracein interfaceSystemRegistry- Parameters:
exception- exception to print on terminal
-
trace
public void trace(boolean stack, Throwable exception)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
public ConsoleEngine consoleEngine()
-
-