public class ConsoleEngineImpl extends JlineCommandRegistry implements ConsoleEngine
| Modifier and Type | Class and Description |
|---|---|
static class |
ConsoleEngineImpl.Command |
ConsoleEngine.ExecutionResult, ConsoleEngine.WidgetCreatorCommandRegistry.CommandSession| Constructor and Description |
|---|
ConsoleEngineImpl(ScriptEngine engine,
Printer printer,
Supplier<Path> workDir,
ConfigurationPath configPath) |
ConsoleEngineImpl(Set<ConsoleEngineImpl.Command> commands,
ScriptEngine engine,
Printer printer,
Supplier<Path> workDir,
ConfigurationPath configPath) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
consoleOption(String option,
T defval)
Read console option value
|
Object |
execute(File script,
String cmdLine,
String[] args)
Executes either JLine or ScriptEngine script.
|
Object |
execute(String cmd,
String line,
String[] args)
Executes command line that does not contain known command by the system registry.
|
boolean |
executeWidget(Object function)
Execute widget function
|
String |
expandCommandLine(String line)
Substitutes command line with system registry invoke method call.
|
Object[] |
expandParameters(String[] args)
Substituting args references with their values.
|
String |
expandToList(List<String> params)
Expands parameter list to string
|
String |
getAlias(String name)
Returns alias 'name' value
|
List<String> |
getNamedPipes()
Returns named pipe names
|
Map<String,List<String>> |
getPipes()
Returns defined pipes
|
Object |
getVariable(String name)
Get variable value
|
boolean |
hasAlias(String name)
Returns true if alias 'name' exists
|
boolean |
hasVariable(String name)
Test if variable with name exists
|
Object |
invoke(CommandRegistry.CommandSession session,
String command,
Object... args)
Execute a command.
|
boolean |
isExecuting() |
void |
persist(Path file,
Object object)
Persist object to file
|
ConsoleEngine.ExecutionResult |
postProcess(Object result)
Post processes execution result.
|
ConsoleEngine.ExecutionResult |
postProcess(String line,
Object result,
String output)
Post processes execution result.
|
void |
println(Object object)
Print object.
|
void |
purge()
Delete temporary console variables
|
void |
putVariable(String name,
Object value)
Create console variable
|
List<org.jline.reader.Completer> |
scriptCompleters()
Returns script and variable completers
|
Map<String,Boolean> |
scripts()
Returns all scripts found from PATH
|
void |
setLineReader(org.jline.reader.LineReader reader)
Sets lineReader
|
void |
setScriptExtension(String extension)
Sets file name extension used by console scripts
|
void |
setSystemRegistry(SystemRegistry systemRegistry)
Sets systemRegistry
|
Object |
slurp(Path file)
Read object from file
|
void |
trace(Object object) |
commandDescription, commandInfo, commandOptions, compileCommandDescription, compileCommandInfo, compileCommandOptions, defaultCompleter, parseOptionsalias, commandAliases, commandNames, compileCompleters, doHelpDesc, getCommandMethods, hasCommand, registerCommands, registerCommands, registeredCommand, rename, saveExceptionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecute, plainCommandaggregateCompleters, commandAliases, commandDescription, commandInfo, commandNames, compileCompleters, compileCompleters, hasCommand, namepublic ConsoleEngineImpl(ScriptEngine engine, Printer printer, Supplier<Path> workDir, ConfigurationPath configPath) throws IOException
IOExceptionpublic ConsoleEngineImpl(Set<ConsoleEngineImpl.Command> commands, ScriptEngine engine, Printer printer, Supplier<Path> workDir, ConfigurationPath configPath) throws IOException
IOExceptionpublic void setLineReader(org.jline.reader.LineReader reader)
ConsoleEnginesetLineReader in interface ConsoleEnginereader - LineReaderpublic boolean isExecuting()
isExecuting in interface ConsoleEnginepublic void setSystemRegistry(SystemRegistry systemRegistry)
ConsoleEnginesetSystemRegistry in interface ConsoleEnginesystemRegistry - SystemRegistrypublic void setScriptExtension(String extension)
ConsoleEnginesetScriptExtension in interface ConsoleEngineextension - console script file extensionpublic boolean hasAlias(String name)
ConsoleEnginehasAlias in interface ConsoleEnginename - alias namepublic String getAlias(String name)
ConsoleEnginegetAlias in interface ConsoleEnginename - alias namepublic Map<String,List<String>> getPipes()
ConsoleEnginegetPipes in interface ConsoleEnginepublic List<String> getNamedPipes()
ConsoleEnginegetNamedPipes in interface ConsoleEnginepublic List<org.jline.reader.Completer> scriptCompleters()
ConsoleEnginescriptCompleters in interface ConsoleEnginepublic Map<String,Boolean> scripts()
ConsoleEnginescripts in interface ConsoleEnginepublic Object[] expandParameters(String[] args) throws Exception
ConsoleEngineexpandParameters in interface ConsoleEngineargs - the arguments to be expandedException - in case of errorpublic String expandToList(List<String> params)
ConsoleEngineexpandToList in interface ConsoleEngineparams - list of script parameterspublic Object execute(File script, String cmdLine, String[] args) throws Exception
ConsoleEngineexecute in interface ConsoleEnginescript - script filecmdLine - raw command lineargs - script argumentsException - in case of errorpublic String expandCommandLine(String line)
ConsoleEngineexpandCommandLine in interface ConsoleEngineline - command line to be expandedpublic Object execute(String cmd, String line, String[] args) throws Exception
ConsoleEngineexecute in interface ConsoleEnginecmd - parsed command/script nameline - raw command lineargs - parsed arguments of the commandException - in case of errorpublic void purge()
ConsoleEnginepurge in interface ConsoleEnginepublic void putVariable(String name, Object value)
ConsoleEngineputVariable in interface ConsoleEnginename - name of the variablevalue - value of the variablepublic Object getVariable(String name)
ConsoleEnginegetVariable in interface ConsoleEnginename - name of the variablepublic boolean hasVariable(String name)
ConsoleEnginehasVariable in interface ConsoleEnginename - name of the variablepublic boolean executeWidget(Object function)
ConsoleEngineexecuteWidget in interface ConsoleEnginefunction - to executepublic <T> T consoleOption(String option, T defval)
ConsoleEngineconsoleOption in interface ConsoleEngineT - option typeoption - option namedefval - default valuepublic ConsoleEngine.ExecutionResult postProcess(String line, Object result, String output)
ConsoleEnginepostProcess in interface ConsoleEngineline - command lineresult - command result to processoutput - command redirected outputpublic ConsoleEngine.ExecutionResult postProcess(Object result)
ConsoleEnginepostProcess in interface ConsoleEngineresult - command result to processpublic Object invoke(CommandRegistry.CommandSession session, String command, Object... args) throws Exception
CommandRegistryinvoke in interface CommandRegistryinvoke in class AbstractCommandRegistrysession - the data of the current command sessioncommand - the name of the commandargs - arguments of the commandException - in case of errorpublic void trace(Object object)
trace in interface ConsoleEngineobject - object to printpublic void println(Object object)
ConsoleEngineprintln in interface ConsoleEngineobject - object to printpublic void persist(Path file, Object object)
ConsoleEnginepersist in interface ConsoleEnginefile - file where object should be writtenobject - object to persistpublic Object slurp(Path file) throws IOException
ConsoleEngineslurp in interface ConsoleEnginefile - file from where object should be readIOException - in case of errorCopyright © 2020. All rights reserved.