Package org.jline.console
Interface ConsoleEngine
-
- All Superinterfaces:
CommandRegistry
- All Known Implementing Classes:
ConsoleEngineImpl
public interface ConsoleEngine extends CommandRegistry
Manage console variables, commands and script executions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classConsoleEngine.ExecutionResultstatic classConsoleEngine.WidgetCreator-
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSession
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> TconsoleOption(java.lang.String option, T defval)Read console option valuedefault java.lang.Objectexecute(java.io.File script)Executes either JLine or ScriptEngine script.java.lang.Objectexecute(java.io.File script, java.lang.String rawLine, java.lang.String[] args)Executes either JLine or ScriptEngine script.java.lang.Objectexecute(java.lang.String name, java.lang.String rawLine, java.lang.String[] args)Executes command line that does not contain known command by the system registry.booleanexecuteWidget(java.lang.Object function)Execute widget functionjava.lang.StringexpandCommandLine(java.lang.String line)Substitutes command line with system registry invoke method call.java.lang.Object[]expandParameters(java.lang.String[] args)Substituting args references with their values.java.lang.StringexpandToList(java.util.List<java.lang.String> params)Expands parameter list to stringjava.lang.StringgetAlias(java.lang.String name)Returns alias 'name' valuejava.util.List<java.lang.String>getNamedPipes()Returns named pipe namesjava.util.Map<java.lang.String,java.util.List<java.lang.String>>getPipes()Returns defined pipesjava.lang.ObjectgetVariable(java.lang.String name)Get variable valuebooleanhasAlias(java.lang.String name)Returns true if alias 'name' existsbooleanhasVariable(java.lang.String name)Test if variable with name existsbooleanisExecuting()voidpersist(java.nio.file.Path file, java.lang.Object object)Persist object to filestatic java.lang.StringplainCommand(java.lang.String command)Removes the command name first character if it is colonConsoleEngine.ExecutionResultpostProcess(java.lang.Object result)Post processes execution result.ConsoleEngine.ExecutionResultpostProcess(java.lang.String line, java.lang.Object result, java.lang.String output)Post processes execution result.voidprintln(java.lang.Object object)Print object.voidpurge()Delete temporary console variablesvoidputVariable(java.lang.String name, java.lang.Object value)Create console variablejava.util.List<Completer>scriptCompleters()Returns script and variable completersjava.util.Map<java.lang.String,java.lang.Boolean>scripts()Returns all scripts found from PATHvoidsetLineReader(LineReader reader)Sets lineReadervoidsetScriptExtension(java.lang.String extension)Sets file name extension used by console scriptsvoidsetSystemRegistry(SystemRegistry systemRegistry)Sets systemRegistryjava.lang.Objectslurp(java.nio.file.Path file)Read object from filevoidtrace(java.lang.Object object)-
Methods inherited from interface org.jline.console.CommandRegistry
commandAliases, commandDescription, commandInfo, commandNames, compileCompleters, hasCommand, invoke, name
-
-
-
-
Method Detail
-
plainCommand
static java.lang.String plainCommand(java.lang.String command)
Removes the command name first character if it is colon- Parameters:
command- the name of the command to complete- Returns:
- command name without starting colon
-
setLineReader
void setLineReader(LineReader reader)
Sets lineReader- Parameters:
reader- LineReader
-
setSystemRegistry
void setSystemRegistry(SystemRegistry systemRegistry)
Sets systemRegistry- Parameters:
systemRegistry- SystemRegistry
-
expandParameters
java.lang.Object[] expandParameters(java.lang.String[] args) throws java.lang.ExceptionSubstituting args references with their values.- Parameters:
args- the arguments to be expanded- Returns:
- expanded arguments
- Throws:
java.lang.Exception- in case of error
-
expandCommandLine
java.lang.String expandCommandLine(java.lang.String line)
Substitutes command line with system registry invoke method call.- Parameters:
line- command line to be expanded- Returns:
- expanded command line
-
expandToList
java.lang.String expandToList(java.util.List<java.lang.String> params)
Expands parameter list to string- Parameters:
params- list of script parameters- Returns:
- expanded parameters list
-
scripts
java.util.Map<java.lang.String,java.lang.Boolean> scripts()
Returns all scripts found from PATH- Returns:
- map keys have script file names and value is true if it is console script
-
setScriptExtension
void setScriptExtension(java.lang.String extension)
Sets file name extension used by console scripts- Parameters:
extension- console script file extension
-
hasAlias
boolean hasAlias(java.lang.String name)
Returns true if alias 'name' exists- Parameters:
name- alias name- Returns:
- true if alias exists
-
getAlias
java.lang.String getAlias(java.lang.String name)
Returns alias 'name' value- Parameters:
name- alias name- Returns:
- value of alias
-
getPipes
java.util.Map<java.lang.String,java.util.List<java.lang.String>> getPipes()
Returns defined pipes- Returns:
- map of defined pipes
-
getNamedPipes
java.util.List<java.lang.String> getNamedPipes()
Returns named pipe names- Returns:
- list of named pipe names
-
scriptCompleters
java.util.List<Completer> scriptCompleters()
Returns script and variable completers- Returns:
- script and variable completers
-
persist
void persist(java.nio.file.Path file, java.lang.Object object)Persist object to file- Parameters:
file- file where object should be writtenobject- object to persist
-
slurp
java.lang.Object slurp(java.nio.file.Path file) throws java.io.IOExceptionRead object from file- Parameters:
file- file from where object should be read- Returns:
- object
- Throws:
java.io.IOException- in case of error
-
consoleOption
<T> T consoleOption(java.lang.String option, T defval)Read console option value- Type Parameters:
T- option type- Parameters:
option- option namedefval- default value- Returns:
- option value
-
execute
java.lang.Object execute(java.lang.String name, java.lang.String rawLine, java.lang.String[] args) throws java.lang.ExceptionExecutes command line that does not contain known command by the system registry. If the line is neither JLine or ScriptEngine script it will be evaluated as ScriptEngine statement.- Parameters:
name- parsed command/script namerawLine- raw command lineargs- parsed arguments of the command- Returns:
- command line execution result
- Throws:
java.lang.Exception- in case of error
-
execute
default java.lang.Object execute(java.io.File script) throws java.lang.ExceptionExecutes either JLine or ScriptEngine script.- Parameters:
script- script file- Returns:
- script execution result
- Throws:
java.lang.Exception- in case of error
-
execute
java.lang.Object execute(java.io.File script, java.lang.String rawLine, java.lang.String[] args) throws java.lang.ExceptionExecutes either JLine or ScriptEngine script.- Parameters:
script- script filerawLine- raw command lineargs- script arguments- Returns:
- script execution result
- Throws:
java.lang.Exception- in case of error
-
postProcess
ConsoleEngine.ExecutionResult postProcess(java.lang.String line, java.lang.Object result, java.lang.String output)
Post processes execution result. If result is to be assigned to the console variable then method will return null.- Parameters:
line- command lineresult- command result to processoutput- command redirected output- Returns:
- processed result
-
postProcess
ConsoleEngine.ExecutionResult postProcess(java.lang.Object result)
Post processes execution result.- Parameters:
result- command result to process- Returns:
- processed result
-
trace
void trace(java.lang.Object object)
- Parameters:
object- object to print
-
println
void println(java.lang.Object object)
Print object.- Parameters:
object- object to print
-
putVariable
void putVariable(java.lang.String name, java.lang.Object value)Create console variable- Parameters:
name- name of the variablevalue- value of the variable
-
getVariable
java.lang.Object getVariable(java.lang.String name)
Get variable value- Parameters:
name- name of the variable- Returns:
- variable value
-
hasVariable
boolean hasVariable(java.lang.String name)
Test if variable with name exists- Parameters:
name- name of the variable- Returns:
- true if variable with name exists
-
purge
void purge()
Delete temporary console variables
-
executeWidget
boolean executeWidget(java.lang.Object function)
Execute widget function- Parameters:
function- to execute- Returns:
- true on success
-
isExecuting
boolean isExecuting()
- Returns:
- true if consoleEngine is executing script
-
-