Package org.jline.console.impl
Class ConsoleEngineImpl
java.lang.Object
org.jline.console.impl.AbstractCommandRegistry
org.jline.console.impl.JlineCommandRegistry
org.jline.console.impl.ConsoleEngineImpl
- All Implemented Interfaces:
CommandRegistry
,ConsoleEngine
Manage console variables, commands and script execution.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
static enum
private class
private static class
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSession
Nested classes/interfaces inherited from interface org.jline.console.ConsoleEngine
ConsoleEngine.ExecutionResult, ConsoleEngine.WidgetCreator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Path
private static final String
private final ScriptEngine
private Exception
private boolean
private static final int
private static final String[]
private static final String
private final Printer
private LineReader
private String
private static final String
private SystemRegistry
private static final String
private static final String
Fields inherited from interface org.jline.console.ConsoleEngine
VAR_NANORC
-
Constructor Summary
ConstructorsConstructorDescriptionConsoleEngineImpl
(Set<ConsoleEngineImpl.Command> commands, ScriptEngine engine, Printer printer, Supplier<Path> workDir, ConfigurationPath configPath) ConsoleEngineImpl
(ScriptEngine engine, Printer printer, Supplier<Path> workDir, ConfigurationPath configPath) -
Method Summary
Modifier and TypeMethodDescriptionprivate Object
aliascmd
(CommandInput input) aliasCompleter
(String command) private boolean
consoleOption
(String option) <T> T
consoleOption
(String option, T defval) Read console option valueprivate Object
del
(CommandInput input) private Object
doc
(CommandInput input) docCompleter
(String command) docs()
private void
Executes either JLine or ScriptEngine script.Executes command line that does not contain known command by the system registry.boolean
executeWidget
(Object function) Execute widget functionexpandCommandLine
(String line) Substitutes command line with system registry invoke method call.private String
expandName
(String name) Object[]
expandParameters
(String[] args) Substituting args references with their values.private String
expandToList
(String[] args) expandToList
(List<String> params) Expands parameter list to stringReturns alias 'name' valueReturns named pipe namesgetPipes()
Returns defined pipesgetVariable
(String name) Get variable valueboolean
Returns true if alias 'name' existsboolean
hasVariable
(String name) Test if variable with name existsinvoke
(CommandRegistry.CommandSession session, String command, Object... args) Execute a command.private boolean
isCodeBlock
(String line) private boolean
isCommandLine
(String line) boolean
private boolean
private Parser
parser()
void
Persist object to fileprivate Object
pipe
(CommandInput input) postProcess
(Object result) Post processes execution result.private ConsoleEngine.ExecutionResult
postProcess
(String line, Object result) postProcess
(String line, Object result, String output) Post processes execution result.void
Print object.private Object
prnt
(CommandInput input) prntCompleter
(String command) void
purge()
Delete temporary console variablesvoid
putVariable
(String name, Object value) Create console variableprivate String
private int
saveResult
(String var, Object result) Returns script and variable completersscripts()
Returns all scripts found from PATHvoid
setConsoleOption
(String name, Object value) Set console option valuevoid
setLineReader
(LineReader reader) Sets lineReadervoid
setScriptExtension
(String extension) Sets file name extension used by console scriptsvoid
setSystemRegistry
(SystemRegistry systemRegistry) Sets systemRegistryprivate Object
show
(CommandInput input) Read object from fileprivate Object
private Object
slurpcmd
(CommandInput input) slurpCompleter
(String command) private Terminal
terminal()
void
private Object
unalias
(CommandInput input) unaliasCompleter
(String command) private boolean
variableCompleter
(String command) Methods inherited from class org.jline.console.impl.JlineCommandRegistry
commandDescription, commandInfo, commandOptions, compileCommandDescription, compileCommandInfo, compileCommandOptions, defaultCompleter, parseOptions
Methods inherited from class org.jline.console.impl.AbstractCommandRegistry
alias, commandAliases, commandNames, compileCompleters, doHelpDesc, getCommandMethods, hasCommand, registerCommands, registerCommands, registeredCommand, rename, saveException
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
commandAliases, commandDescription, commandInfo, commandNames, compileCompleters, hasCommand, name
Methods inherited from interface org.jline.console.ConsoleEngine
execute
-
Field Details
-
VAR_CONSOLE_OPTIONS
- See Also:
-
VAR_PATH
- See Also:
-
OPTION_HELP
-
OPTION_VERBOSE
- See Also:
-
SLURP_FORMAT_TEXT
- See Also:
-
END_HELP
- See Also:
-
HELP_MAX_SIZE
private static final int HELP_MAX_SIZE- See Also:
-
engine
-
exception
-
systemRegistry
-
scriptExtension
-
workDir
-
aliases
-
pipes
-
aliasFile
-
reader
-
executing
private boolean executing -
printer
-
-
Constructor Details
-
ConsoleEngineImpl
public ConsoleEngineImpl(ScriptEngine engine, Printer printer, Supplier<Path> workDir, ConfigurationPath configPath) throws IOException - Throws:
IOException
-
ConsoleEngineImpl
public ConsoleEngineImpl(Set<ConsoleEngineImpl.Command> commands, ScriptEngine engine, Printer printer, Supplier<Path> workDir, ConfigurationPath configPath) throws IOException - Throws:
IOException
-
-
Method Details
-
setLineReader
Description copied from interface:ConsoleEngine
Sets lineReader- Specified by:
setLineReader
in interfaceConsoleEngine
- Parameters:
reader
- LineReader
-
parser
-
terminal
-
isExecuting
public boolean isExecuting()- Specified by:
isExecuting
in interfaceConsoleEngine
- Returns:
- true if consoleEngine is executing script
-
setSystemRegistry
Description copied from interface:ConsoleEngine
Sets systemRegistry- Specified by:
setSystemRegistry
in interfaceConsoleEngine
- Parameters:
systemRegistry
- SystemRegistry
-
setScriptExtension
Description copied from interface:ConsoleEngine
Sets file name extension used by console scripts- Specified by:
setScriptExtension
in interfaceConsoleEngine
- Parameters:
extension
- console script file extension
-
hasAlias
Description copied from interface:ConsoleEngine
Returns true if alias 'name' exists- Specified by:
hasAlias
in interfaceConsoleEngine
- Parameters:
name
- alias name- Returns:
- true if alias exists
-
getAlias
Description copied from interface:ConsoleEngine
Returns alias 'name' value- Specified by:
getAlias
in interfaceConsoleEngine
- Parameters:
name
- alias name- Returns:
- value of alias
-
getPipes
Description copied from interface:ConsoleEngine
Returns defined pipes- Specified by:
getPipes
in interfaceConsoleEngine
- Returns:
- map of defined pipes
-
getNamedPipes
Description copied from interface:ConsoleEngine
Returns named pipe names- Specified by:
getNamedPipes
in interfaceConsoleEngine
- Returns:
- list of named pipe names
-
scriptCompleters
Description copied from interface:ConsoleEngine
Returns script and variable completers- Specified by:
scriptCompleters
in interfaceConsoleEngine
- Returns:
- script and variable completers
-
commandAliasNames
-
scriptNames
-
scripts
Description copied from interface:ConsoleEngine
Returns all scripts found from PATH- Specified by:
scripts
in interfaceConsoleEngine
- Returns:
- map keys have script file names and value is true if it is console script
-
expandParameters
Description copied from interface:ConsoleEngine
Substituting args references with their values.- Specified by:
expandParameters
in interfaceConsoleEngine
- Parameters:
args
- the arguments to be expanded- Returns:
- expanded arguments
- Throws:
Exception
- in case of error
-
expandToList
-
expandToList
Description copied from interface:ConsoleEngine
Expands parameter list to string- Specified by:
expandToList
in interfaceConsoleEngine
- Parameters:
params
- list of script parameters- Returns:
- expanded parameters list
-
expandName
-
isNumber
-
isCodeBlock
-
isCommandLine
-
quote
-
scriptExtensions
-
execute
Description copied from interface:ConsoleEngine
Executes either JLine or ScriptEngine script.- Specified by:
execute
in interfaceConsoleEngine
- Parameters:
script
- script filecmdLine
- raw command lineargs
- script arguments- Returns:
- script execution result
- Throws:
Exception
- in case of error
-
expandCommandLine
Description copied from interface:ConsoleEngine
Substitutes command line with system registry invoke method call.- Specified by:
expandCommandLine
in interfaceConsoleEngine
- Parameters:
line
- command line to be expanded- Returns:
- expanded command line
-
execute
Description copied from interface:ConsoleEngine
Executes 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.- Specified by:
execute
in interfaceConsoleEngine
- Parameters:
cmd
- parsed command/script nameline
- raw command lineargs
- parsed arguments of the command- Returns:
- command line execution result
- Throws:
Exception
- in case of error
-
purge
public void purge()Description copied from interface:ConsoleEngine
Delete temporary console variables- Specified by:
purge
in interfaceConsoleEngine
-
putVariable
Description copied from interface:ConsoleEngine
Create console variable- Specified by:
putVariable
in interfaceConsoleEngine
- Parameters:
name
- name of the variablevalue
- value of the variable
-
getVariable
Description copied from interface:ConsoleEngine
Get variable value- Specified by:
getVariable
in interfaceConsoleEngine
- Parameters:
name
- name of the variable- Returns:
- variable value
-
hasVariable
Description copied from interface:ConsoleEngine
Test if variable with name exists- Specified by:
hasVariable
in interfaceConsoleEngine
- Parameters:
name
- name of the variable- Returns:
- true if variable with name exists
-
executeWidget
Description copied from interface:ConsoleEngine
Execute widget function- Specified by:
executeWidget
in interfaceConsoleEngine
- Parameters:
function
- to execute- Returns:
- true on success
-
consoleOptions
-
consoleOption
Description copied from interface:ConsoleEngine
Read console option value- Specified by:
consoleOption
in interfaceConsoleEngine
- Type Parameters:
T
- option type- Parameters:
option
- option namedefval
- default value- Returns:
- option value
-
setConsoleOption
Description copied from interface:ConsoleEngine
Set console option value- Specified by:
setConsoleOption
in interfaceConsoleEngine
- Parameters:
name
- the option namevalue
- value to assign console option
-
consoleOption
-
postProcess
Description copied from interface:ConsoleEngine
Post processes execution result. If result is to be assigned to the console variable then method will return null.- Specified by:
postProcess
in interfaceConsoleEngine
- Parameters:
line
- command lineresult
- command result to processoutput
- command redirected output- Returns:
- processed result
-
postProcess
-
postProcess
Description copied from interface:ConsoleEngine
Post processes execution result.- Specified by:
postProcess
in interfaceConsoleEngine
- Parameters:
result
- command result to process- Returns:
- processed result
-
saveResult
-
invoke
public Object invoke(CommandRegistry.CommandSession session, String command, Object... args) throws Exception Description copied from interface:CommandRegistry
Execute a command.- Specified by:
invoke
in interfaceCommandRegistry
- Overrides:
invoke
in classAbstractCommandRegistry
- Parameters:
session
- the data of the current command sessioncommand
- the name of the commandargs
- arguments of the command- Returns:
- result of the command execution
- Throws:
Exception
- in case of error
-
trace
- Specified by:
trace
in interfaceConsoleEngine
- Parameters:
object
- object to print
-
error
-
println
Description copied from interface:ConsoleEngine
Print object.- Specified by:
println
in interfaceConsoleEngine
- Parameters:
object
- object to print
-
show
-
del
-
prnt
-
slurpcmd
-
persist
Description copied from interface:ConsoleEngine
Persist object to file- Specified by:
persist
in interfaceConsoleEngine
- Parameters:
file
- file where object should be writtenobject
- object to persist
-
slurp
Description copied from interface:ConsoleEngine
Read object from file- Specified by:
slurp
in interfaceConsoleEngine
- Parameters:
file
- file from where object should be read- Returns:
- object
- Throws:
IOException
- in case of error
-
slurp
- Throws:
IOException
-
aliascmd
-
unalias
-
pipe
-
doc
-
urlExists
-
slurpCompleter
-
variableCompleter
-
prntCompleter
-
aliasCompleter
-
unaliasCompleter
-
docs
-
docCompleter
-