lucee.Component
commandbox.system.services.CommandService
Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I handle initializing, reading, and running commands
| Property Summary | ||||
|---|---|---|---|---|
| type | property | default | serializable | required |
any
|
commandLocations
|
true
|
false
|
|
any
|
ConfigService
|
true
|
false
|
|
boolean
|
configured
|
false
|
true
|
false
|
any
|
consoleLogger
|
true
|
false
|
|
any
|
cr
|
true
|
false
|
|
any
|
fileSystemUtil
|
true
|
false
|
|
any
|
FRTransService
|
true
|
false
|
|
any
|
interceptorService
|
true
|
false
|
|
any
|
logger
|
true
|
false
|
|
any
|
metadataCache
|
true
|
false
|
|
any
|
parser
|
true
|
false
|
|
any
|
shell
|
true
|
false
|
|
any
|
stringDistance
|
true
|
false
|
|
any
|
system
|
true
|
false
|
|
any
|
SystemSettings
|
true
|
false
|
|
any
|
wirebox
|
true
|
false
|
|
| Constructor Summary | |
|---|---|
|
init()
Constructor. |
|
| Method Summary | |
|---|---|
private any
|
addDefaultParameters([any commandString], [any parameterInfo])
Merge in parameter defaults. |
any
|
addToDictionary(any command, any commandPath)
|
private any
|
breakTokensIntoChain(array tokens)
Takes a single array of tokens and breaks it into a chain of commands (array of arrays). |
any
|
combineColonParams(struct parameters)
Look through named parameters and combine any ones with a colon based on matching prefixes. |
CommandService
|
configure()
Configure the service. |
any
|
convertToNamedParameters([any userPositionalParams], [any commandParams])
Match positional parameters up with their names. |
private struct
|
createCommandData(any fullCFCPath, any commandName)
Create command metadata. |
private any
|
createGlobs([any parameterInfo], [any commandParams])
Check for Globber parameters and create actual Globber object out of them. |
any
|
ensureRequiredparams([any userNamedParams], [any commandParams])
Make sure we have all required params. |
any
|
evaluateExpressions(any parameterInfo)
Evaluates any expressions as a command string and puts the output in its place. |
any
|
evaluateSystemSettings(any parameterInfo)
Evaluates any system settings and puts the output in its place. |
any
|
generateListOfSimilarCommands(struct commandInfo)
Generate a smart list of possible commands that the user meant to type. |
array
|
getCallStack()
Get the array of commands being executed. |
any
|
getCommandHierarchy()
return the nested command structure. |
string
|
getCommandLocations()
|
any
|
getCommands()
return the command structure. |
string
|
getConfigService()
|
string
|
getConfigured()
|
string
|
getConsoleLogger()
|
string
|
getCr()
|
string
|
getFileSystemUtil()
|
string
|
getFRTransService()
|
string
|
getInterceptorService()
|
string
|
getLogger()
|
string
|
getMetadataCache()
|
string
|
getParser()
|
string
|
getShell()
|
string
|
getStringDistance()
|
string
|
getSystem()
|
string
|
getSystemSettings()
|
string
|
getWirebox()
|
any
|
inCommand([any command=''])
Looks at the call stack to determine if we're currently "inside" a command. |
CommandService
|
initCommands(string baseCommandDirectory, string commandDirectory, [string commandPath=''])
Initialize the commands. |
any
|
isCommandCFC(struct commandData)
checks if given cfc name is a valid command component. |
private any
|
lazyLoadCommandCFC([any commandData])
Takes a struct of command data and lazy loads the actual CFC isntance if neccessary. |
any
|
listCommands()
return a list of base commands. |
private any
|
mergeFlagParameters(struct parameterInfo)
Merge flags into named parameters. |
any
|
parseParameters([any parameters], [any commandParameters])
Take an array of parameters and parse them out as named or positional. |
private any
|
registerCommand([any baseCommandDirectory], [any CFC], [any commandPath])
load command CFC. |
any
|
resolveCommand(string line, [boolean forCompletion='false'])
Figure out what command to run based on the the user input string. |
any
|
resolveCommandTokens(array tokens, [string rawLine='[runtime expression]'], [boolean forCompletion='false'])
Figure out what command to run based on the tokenized user input. |
any
|
runCommand(array commandChain, string line, [string piped], [boolean captureOutput='false'])
run a command. |
any
|
runCommandline(string line, [boolean captureOutput='false'])
run a command line. |
any
|
runCommandTokens(array tokens, [string piped], [boolean captureOutput='false'])
run a command tokens. |
any
|
setCommandLocations(any commandLocations)
|
any
|
setConfigService(any ConfigService)
|
any
|
setConfigured(boolean configured)
|
any
|
setConsoleLogger(any consoleLogger)
|
any
|
setCr(any cr)
|
any
|
setFileSystemUtil(any fileSystemUtil)
|
any
|
setFRTransService(any FRTransService)
|
any
|
setInterceptorService(any interceptorService)
|
any
|
setLogger(any logger)
|
any
|
setMetadataCache(any metadataCache)
|
any
|
setParser(any parser)
|
any
|
setShell(any shell)
|
any
|
setStringDistance(any stringDistance)
|
any
|
setSystem(any system)
|
any
|
setSystemSettings(any SystemSettings)
|
any
|
setWirebox(any wirebox)
|
private any
|
validateParams([any userNamedParams], [any commandParams])
Make sure all params are the correct type. |
| Methods inherited from class lucee.Component |
|---|
| None |
| Constructor Detail |
|---|
Constructor
| Property Detail |
|---|
access - publicrequired - falsereturntype - anyinject - commandLocations@constantsserializable - trueaccess - publicrequired - falsereturntype - anyinject - ConfigServiceserializable - trueaccess - publicrequired - falsereturntype - anyserializable - trueaccess - publicrequired - falsereturntype - anyinject - logbox:logger:consoleserializable - trueaccess - publicrequired - falsereturntype - anyinject - cr@constantsserializable - trueaccess - publicrequired - falsereturntype - anyinject - FileSystemserializable - trueaccess - publicrequired - falsereturntype - anyinject - FRTransServiceserializable - trueaccess - publicrequired - falsereturntype - anyinject - interceptorServiceserializable - trueaccess - publicrequired - falsereturntype - anyinject - logbox:logger:{this}serializable - trueaccess - publicrequired - falsereturntype - anyinject - cachebox:metadataCacheserializable - trueaccess - publicrequired - falsereturntype - anyinject - Parserserializable - trueaccess - publicrequired - falsereturntype - anyinject - Shellserializable - trueaccess - publicrequired - falsereturntype - anyinject - provider:StringSimilarity@string-similarityserializable - trueaccess - publicrequired - falsereturntype - anyinject - System@constantsserializable - trueaccess - publicrequired - falsereturntype - anyinject - SystemSettingsserializable - trueaccess - publicrequired - falsereturntype - anyinject - wireboxserializable - true| Method Detail |
|---|
Merge in parameter defaults
commandStringparameterInfocommandcommandPathTakes a single array of tokens and breaks it into a chain of commands (array of arrays) i.e. foo bar | baz turns into [ [ 'foo', 'bar' ], [ '|' ], [ 'baz' ] ]
tokensLook through named parameters and combine any ones with a colon based on matching prefixes.
parametersConfigure the service
Match positional parameters up with their names
userPositionalParamscommandParamsCreate command metadata
fullCFCPath - the full CFC pathcommandName - the command nameCheck for Globber parameters and create actual Globber object out of them
parameterInfocommandParamsMake sure we have all required params
userNamedParamscommandParamsEvaluates any expressions as a command string and puts the output in its place.
parameterInfoEvaluates any system settings and puts the output in its place.
parameterInfoGenerate a smart list of possible commands that the user meant to type
commandInfoGet the array of commands being executed. This may be empty.
return the nested command structure
return the command structure
Looks at the call stack to determine if we're currently "inside" a command. Useful to prevent endless recursion.
command - Name of the command to look for as typed from the shell. If empty, returns true for any commandInitialize the commands. This will recursively call itself for subdirectories.
baseCommandDirectory - The starting directorycommandDirectory - The current directory we've recursed intocommandPath - The dot-delimted path so far-- only used when recursingchecks if given cfc name is a valid command component
commandData - the command metadataTakes a struct of command data and lazy loads the actual CFC isntance if neccessary
commandData - Struct created by registerCommand()return a list of base commands
Merge flags into named parameters
parameterInfoTake an array of parameters and parse them out as named or positional
parameters - The array of params to parse.commandParameters - valid params defined by the commandload command CFC
baseCommandDirectory - The base directory for this commandCFC - CFC name that represents the commandcommandPath - The relative dot-delimted path to the CFC starting in the commands dirFigure out what command to run based on the the user input string
line - A string containing the command and parameters that the user enteredforCompletionFigure out what command to run based on the tokenized user input
tokens - An array containing the command and parameters that the user enteredrawLineforCompletionrun a command
commandChain - the chain of commands to runlinepipedcaptureOutput - Temp workaround to allow capture of run commandrun a command line
line - line to runcaptureOutput - Temp workaround to allow capture of run commandrun a command tokens
tokens - tokens to runpiped - Data to pipe in to the first commandcaptureOutput - Temp workaround to allow capture of run commandcommandLocationsConfigServiceconfiguredconsoleLoggercrfileSystemUtilFRTransServiceinterceptorServiceloggermetadataCacheparsershellstringDistancesystemSystemSettingswireboxMake sure all params are the correct type
userNamedParamscommandParams