lucee.Componentcommandbox.system.Shell
Copyright Since 2005 ColdBox Platform by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com The CommandBox Shell Object that controls the shell
Property Summary | ||||
---|---|---|---|---|
type | property | default | serializable | required |
any
|
CommandCompletor
|
true
|
false
|
|
any
|
CommandHighlighter
|
true
|
false
|
|
any
|
InterceptorService
|
true
|
false
|
|
any
|
LogBox
|
true
|
false
|
|
any
|
ModuleService
|
true
|
false
|
|
any
|
REPLCompletor
|
true
|
false
|
|
any
|
REPLHighlighter
|
true
|
false
|
|
any
|
Util
|
true
|
false
|
|
any
|
WireBox
|
true
|
false
|
|
any
|
commandService
|
true
|
false
|
|
any
|
configService
|
true
|
false
|
|
any
|
cr
|
true
|
false
|
|
Boolean
|
doClearScreen
Clear screen after reload.
|
false
|
true
|
false
|
any
|
fileSystem
|
true
|
false
|
|
any
|
formatterUtil
|
true
|
false
|
|
Boolean
|
keepRunning
Bit that tells the shell to keep running.
|
true
|
true
|
false
|
any
|
loaderVersion
The loader version number.
|
true
|
false
|
|
any
|
logger
|
true
|
false
|
|
any
|
print
|
true
|
false
|
|
any
|
pwd
The Current Working Directory.
|
true
|
false
|
|
any
|
reader
The java jline reader class.
|
true
|
false
|
|
any
|
readerFactory
|
true
|
false
|
|
Boolean
|
reloadShell
Bit that is used to reload the shell.
|
false
|
true
|
false
|
any
|
shellPrompt
The default shell prompt.
|
true
|
false
|
|
any
|
shellType
This value is either "interactive" meaning the shell stays open waiting for user input.
|
interactive
|
true
|
false
|
any
|
systemSettings
|
true
|
false
|
|
any
|
version
The shell version number.
|
true
|
false
|
Constructor Summary | |
---|---|
init([any inStream], [any outputStream], string userDir, string tempDir, [boolean asyncLoad='true'])
constructor. |
Method Summary | |
---|---|
string
|
ask([any message], [string mask=''], [string defaultResponse=''], [any keepHistory='false'], [any highlight='false'], [any complete='false'])
ask the user a question and wait for response. |
any
|
callCommand(any command, [any returnOutput='false'], [string piped], [boolean initialCommand='false'])
Call a command. |
string
|
cd([any directory=''])
Changes the current directory of the shell and returns the directory set. |
any
|
checkInterrupted([any thisThread])
Call this method periodically in a long-running task to check and see. |
Shell
|
clearScreen()
clears the console. |
boolean
|
confirm(any message)
Ask the user a question looking for a yes/no response. |
any
|
enableCompletion([boolean enable='true'])
Enable or disables tab completion in the shell. |
any
|
enableHighlighter([boolean enable='true'])
Enable or disables highlighting in the shell. |
any
|
enableHistory([boolean enable='true'])
Enable or disables history in the shell. |
Shell
|
exit()
Exists the shell. |
string
|
getCommandCompletor()
|
string
|
getCommandHighlighter()
|
string
|
getCommandService()
|
string
|
getConfigService()
|
string
|
getCr()
|
string
|
getDoClearScreen()
|
any
|
getExitCode()
Gets the last Exit code to be used. |
string
|
getFileSystem()
|
string
|
getFormatterUtil()
|
string
|
getInterceptorService()
|
string
|
getKeepRunning()
|
string
|
getLoaderVersion()
|
string
|
getLogBox()
|
string
|
getLogger()
|
any
|
getMainThread()
|
string
|
getModuleService()
|
string
|
getPrint()
|
string
|
getPwd()
|
string
|
getREPLCompletor()
|
string
|
getREPLHighlighter()
|
string
|
getReader()
|
string
|
getReaderFactory()
|
string
|
getReloadShell()
|
string
|
getShellPrompt()
|
string
|
getShellType()
|
string
|
getSystemSettings()
|
string
|
getTempDir()
Get the temp dir in a safe manner. |
any
|
getTermHeight()
Get's terminal height. |
any
|
getTermWidth()
Get's terminal width. |
string
|
getText()
Returns the current console text. |
string
|
getUtil()
|
string
|
getVersion()
|
string
|
getWireBox()
|
any
|
isTerminalInteractive()
Is the current terminal interactive?. |
any
|
onDIComplete()
Finish configuring the shell. |
Shell
|
printError(any err)
print an error to the console. |
Shell
|
printString(any string)
Prints a string to the reader console with auto flush. |
any
|
pwd()
Alias to get's current directory or use getPWD(). |
Shell
|
reload([Boolean clear='true'])
Sets reload flag, relaoded from shell. |
boolean
|
run([any silent='false'])
Runs the shell thread until exit flag is set. |
any
|
setCommandCompletor(any CommandCompletor)
|
any
|
setCommandHighlighter(any CommandHighlighter)
|
any
|
setCommandService(any commandService)
|
any
|
setCompletor([string completorName], [any executor])
Set the shell's completor. |
any
|
setConfigService(any configService)
|
any
|
setCr(any cr)
|
any
|
setDoClearScreen(Boolean doClearScreen)
|
Shell
|
setExitCode(string exitCode)
Sets the OS Exit code to be used. |
any
|
setFileSystem(any fileSystem)
|
any
|
setFormatterUtil(any formatterUtil)
|
any
|
setHighlighter([string highlighterName])
Set the shell's highlighter. |
any
|
setHistory([any filePath])
Use this wrapper method to change the history file in use by the shell. |
any
|
setInterceptorService(any InterceptorService)
|
any
|
setKeepRunning(Boolean keepRunning)
|
any
|
setLoaderVersion(any loaderVersion)
|
any
|
setLogBox(any LogBox)
|
any
|
setLogger(any logger)
|
any
|
setModuleService(any ModuleService)
|
any
|
setPrint(any print)
|
Shell
|
setPrompt([any text=''])
Sets the shell prompt. |
any
|
setPwd(any pwd)
|
any
|
setREPLCompletor(any REPLCompletor)
|
any
|
setREPLHighlighter(any REPLHighlighter)
|
any
|
setReader(any reader)
|
any
|
setReaderFactory(any readerFactory)
|
any
|
setReloadShell(Boolean reloadShell)
|
any
|
setShellPrompt(any shellPrompt)
|
any
|
setShellType(any shellType)
|
any
|
setSystemSettings(any systemSettings)
|
Shell
|
setTempDir(any directory)
sets and renews temp directory. |
any
|
setUtil(any Util)
|
any
|
setVersion(any version)
|
any
|
setWireBox(any WireBox)
|
any
|
shutdown()
Shutdown the shell and close/release any resources associated. |
string
|
waitForKey([any message=''])
Wait until the user's next keystroke, returns the key pressed. |
Methods inherited from class lucee.Component |
---|
None |
Constructor Detail |
---|
constructor
inStream
- input stream if running externallyoutputStream
- output stream if running externallyuserDir
- The user directorytempDir
- The temp directoryasyncLoad
Property Detail |
---|
access
- publicrequired
- falsereturntype
- anyinject
- CommandCompletorserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- CommandHighlighterserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- InterceptorServiceserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- logboxserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- ModuleServiceserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- REPLCompletorserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- REPLHighlighterserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- wirebox.system.core.util.Utilserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- wireboxserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- CommandServiceserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- configServiceserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- cr@constantsserializable
- trueClear screen after reload
access
- publicrequired
- falsereturntype
- anyserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- FileSystemserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- Formatterserializable
- trueBit that tells the shell to keep running
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe loader version number
access
- publicrequired
- falsereturntype
- anyserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- logbox:logger:{this}serializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- printserializable
- trueThe Current Working Directory
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe java jline reader class.
access
- publicrequired
- falsereturntype
- anyserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- ReaderFactoryserializable
- trueBit that is used to reload the shell
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe default shell prompt
access
- publicrequired
- falsereturntype
- anyserializable
- trueThis value is either "interactive" meaning the shell stays open waiting for user input or "command" which means a single command will be run and then the shell will be exiting. This differentiation may be useful for commands who want to be careful not to leave threads running that they expect to finish since the JVM will terminiate immedatley after the command finishes. This could also be useful to reduce the amount of extra text that's output such as the CommandBox banner which isn't really needed for a one-off command, especially if the output of that command needs to be fed into another OS command.
access
- publicrequired
- falsereturntype
- anyserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- SystemSettingsserializable
- trueThe shell version number
access
- publicrequired
- falsereturntype
- anyserializable
- trueMethod Detail |
---|
ask the user a question and wait for response
message
- message to prompt the user withmask
- When not empty, keyboard input is masked as that characterdefaultResponse
- Text to populate the buffer with by default that will be submitted if the user presses enter without typing anythingkeepHistory
- True to remeber the text typed in the shell historyhighlight
complete
Call a command In other words, if "foo" calls "bar", which calls "baz" and baz errors, all three commands are scrapped and do not finish execution.
command
- Either a string containing a text command, or an array of tokens representing the command and parameters.returnOutput
- True will return the output of the command as a string, false will send the output to the console. If command outputs nothing, an empty string will come back.piped
- Any text being piped into the command. This will overwrite the first parameter (pushing any positional params back)initialCommand
- Since commands can recursivley call new commands via this method, this flags the first in the chain so exceptions can bubble all the way back to the beginning.Changes the current directory of the shell and returns the directory set.
directory
- directory to CD to. Please verify it exists before calling.Call this method periodically in a long-running task to check and see if the user has hit Ctrl-C. This method will throw an UserInterruptException which you should not catch. It will unroll the stack all the way back to the shell
thisThread
clears the console
Ask the user a question looking for a yes/no response
message
- message to prompt the user withEnable or disables tab completion in the shell
enable
- Pass true to enable, false to disableEnable or disables highlighting in the shell
enable
- Pass true to enable, false to disableEnable or disables history in the shell
enable
- Pass true to enable, false to disableExists the shell
Gets the last Exit code to be used
Get the temp dir in a safe manner
Get's terminal height
Get's terminal width
Returns the current console text
Is the current terminal interactive?
Finish configuring the shell
print an error to the console
err
- Error object to print (only message is required)Prints a string to the reader console with auto flush
string
- string to print (handles complex objects)Alias to get's current directory or use getPWD()
Sets reload flag, relaoded from shell.cfm
clear
- clears the screen after reloadRuns the shell thread until exit flag is set
silent
- Supress promptCommandCompletor
CommandHighlighter
commandService
Set the shell's completor
completorName
- Pass "command", "repl", or "dummy"executor
- If using REPL completor, pass an optional executor for better completion resultsconfigService
cr
doClearScreen
Sets the OS Exit code to be used
exitCode
fileSystem
formatterUtil
Set the shell's highlighter
highlighterName
- Pass "command", "repl", or "dummy"Use this wrapper method to change the history file in use by the shell.
filePath
- The path to the history file to setInterceptorService
keepRunning
loaderVersion
LogBox
logger
ModuleService
print
Sets the shell prompt
text
- prompt text to set, if empty we use the default promptpwd
REPLCompletor
REPLHighlighter
reader
readerFactory
reloadShell
shellPrompt
shellType
systemSettings
sets and renews temp directory
directory
- directory to useUtil
version
WireBox
Shutdown the shell and close/release any resources associated. This isn't guaranteed to run if the shell is closed, but it will run for a reload command
Wait until the user's next keystroke, returns the key pressed
message