Package org.jline.console
Interface SystemRegistry
-
- All Superinterfaces:
CommandRegistry
,ConsoleOptionGetter
- All Known Implementing Classes:
SimpleSystemRegistryImpl
,SystemRegistryImpl
public interface SystemRegistry extends CommandRegistry, ConsoleOptionGetter
Aggregate command registries and dispatch command executions.- Author:
- Matti Rinta-Nikkola
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
SystemRegistry.Registeries
Manage systemRegistry store-
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSession
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static void
add(SystemRegistry systemRegistry)
Add systemRegistry to the thread mapvoid
cleanUp()
Delete temporary console variables and reset output streamsvoid
close()
Orderly close SystemRegistry.CmdDesc
commandDescription(CmdLine line)
Returns a command, method or syntax description for use in the JLine Widgets framework.Completer
completer()
Returns command completer that includes also console variable and script completion.java.lang.Object
consoleOption(java.lang.String name)
Return console option value<T> T
consoleOption(java.lang.String name, T defVal)
Return console option valuejava.lang.Object
execute(java.lang.String line)
Execute a command, script or evaluate scriptEngine statementstatic SystemRegistry
get()
java.util.Collection<java.lang.String>
getPipeNames()
void
initialize(java.io.File script)
Initialize consoleEngine environment by executing console scriptjava.lang.Object
invoke(java.lang.String command, java.lang.Object... args)
Execute command with argumentsboolean
isCommandAlias(java.lang.String alias)
Returns whether alias is known command alias.boolean
isCommandOrScript(java.lang.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(java.lang.String command, CommandRegistry subcommandRegistry)
Register subcommand registrystatic void
remove()
Remove systemRegistry of the current thread from the thread mapvoid
setCommandRegistries(CommandRegistry... commandRegistries)
Set command registriesvoid
setConsoleOption(java.lang.String name, java.lang.Object value)
Set console option valueTerminal
terminal()
void
trace(boolean stack, java.lang.Throwable exception)
Print exception on terminalvoid
trace(java.lang.Throwable exception)
Print exception on terminal-
Methods inherited from interface org.jline.console.CommandRegistry
commandAliases, commandDescription, commandInfo, commandNames, compileCompleters, hasCommand, invoke, name
-
-
-
-
Method Detail
-
setCommandRegistries
void setCommandRegistries(CommandRegistry... commandRegistries)
Set command registries- Parameters:
commandRegistries
- command registries used by the application
-
register
void register(java.lang.String command, CommandRegistry subcommandRegistry)
Register subcommand registry- Parameters:
command
- main commandsubcommandRegistry
- subcommand registry
-
initialize
void initialize(java.io.File script)
Initialize consoleEngine environment by executing console script- Parameters:
script
- initialization script
-
getPipeNames
java.util.Collection<java.lang.String> getPipeNames()
- Returns:
- pipe names defined in systemRegistry
-
completer
Completer completer()
Returns command completer that includes also console variable and script completion.- Returns:
- command completer
-
commandDescription
CmdDesc commandDescription(CmdLine line)
Returns a command, method or syntax description for use in the JLine Widgets framework.- Parameters:
line
- command line whose description to return- Returns:
- command description for JLine TailTipWidgets to be displayed in the terminal status bar.
-
execute
java.lang.Object execute(java.lang.String line) throws java.lang.Exception
Execute a command, script or evaluate scriptEngine statement- Parameters:
line
- command line to be executed- Returns:
- execution result
- Throws:
java.lang.Exception
- in case of error
-
cleanUp
void cleanUp()
Delete temporary console variables and reset output streams
-
trace
void trace(java.lang.Throwable exception)
Print exception on terminal- Parameters:
exception
- exception to print on terminal
-
trace
void trace(boolean stack, java.lang.Throwable exception)
Print exception on terminal- Parameters:
stack
- print stack trace if stack true otherwise messageexception
- exception to be printed
-
consoleOption
java.lang.Object consoleOption(java.lang.String name)
Return console option value- Specified by:
consoleOption
in interfaceConsoleOptionGetter
- Parameters:
name
- the option name- Returns:
- option value
-
consoleOption
<T> T consoleOption(java.lang.String name, T defVal)
Return console option value- Specified by:
consoleOption
in interfaceConsoleOptionGetter
- Type Parameters:
T
- option type- Parameters:
name
- the option namedefVal
- value to return if console option does not exists- Returns:
- option value
-
setConsoleOption
void setConsoleOption(java.lang.String name, java.lang.Object value)
Set console option value- Parameters:
name
- the option namevalue
- value to assign console option
-
terminal
Terminal terminal()
- Returns:
- terminal
-
invoke
java.lang.Object invoke(java.lang.String command, java.lang.Object... args) throws java.lang.Exception
Execute command with arguments- Parameters:
command
- command to be executedargs
- arguments of the command- Returns:
- command execution result
- Throws:
java.lang.Exception
- in case of error
-
isCommandOrScript
boolean isCommandOrScript(ParsedLine line)
Returns whether a line contains command/script that is known to this registry.- Parameters:
line
- the parsed command line to test- Returns:
- true if the specified line has a command registered
-
isCommandOrScript
boolean isCommandOrScript(java.lang.String command)
Returns whether command is known to this registry.- Parameters:
command
- the command to test- Returns:
- true if the specified command is known
-
isCommandAlias
boolean isCommandAlias(java.lang.String alias)
Returns whether alias is known command alias.- Parameters:
alias
- the alias to test- Returns:
- true if the alias is known command alias
-
close
void close()
Orderly close SystemRegistry.
-
get
static SystemRegistry get()
- Returns:
- systemRegistry of the current thread
-
add
static void add(SystemRegistry systemRegistry)
Add systemRegistry to the thread map- Parameters:
systemRegistry
- the systemRegistry
-
remove
static void remove()
Remove systemRegistry of the current thread from the thread map
-
-