commandbox.system.services

Class CommandService

lucee.Component
    extended by 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

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Property Summary
    type property default serializable required
    any ConfigService


    • access = public
    • returntype = any
    • inject = ConfigService
    true false
    any FRTransService


    • access = public
    • returntype = any
    • inject = FRTransService
    true false
    any SystemSettings


    • access = public
    • returntype = any
    • inject = SystemSettings
    true false
    any commandLocations


    • access = public
    • returntype = any
    • inject = commandLocations@constants
    true false
    boolean configured


    • access = public
    • returntype = any
    false true false
    any consoleLogger


    • access = public
    • returntype = any
    • inject = logbox:logger:console
    true false
    any cr


    • access = public
    • returntype = any
    • inject = cr@constants
    true false
    any fileSystemUtil


    • access = public
    • returntype = any
    • inject = FileSystem
    true false
    any interceptorService


    • access = public
    • returntype = any
    • inject = interceptorService
    true false
    any logger


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    any metadataCache


    • access = public
    • returntype = any
    • inject = cachebox:metadataCache
    true false
    any parser


    • access = public
    • returntype = any
    • inject = Parser
    true false
    any shell


    • access = public
    • returntype = any
    • inject = Shell
    true false
    any stringDistance


    • access = public
    • returntype = any
    • inject = provider:StringSimilarity@string-similarity
    true false
    any system


    • access = public
    • returntype = any
    • inject = System@constants
    true false
    any wirebox


    • access = public
    • returntype = any
    • inject = 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 getFRTransService()
    string getFileSystemUtil()
    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 runCommandTokens(array tokens, [string piped], [boolean captureOutput='false'])
         run a command tokens.
    any runCommandline(string line, [boolean captureOutput='false'])
         run a command line.
    any setCommandLocations(any commandLocations)
    any setConfigService(any ConfigService)
    any setConfigured(boolean configured)
    any setConsoleLogger(any consoleLogger)
    any setCr(any cr)
    any setFRTransService(any FRTransService)
    any setFileSystemUtil(any fileSystemUtil)
    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

    init

    public init()

    Constructor


    Property Detail

    ConfigService

    property any ConfigService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - ConfigService
    serializable - true

    FRTransService

    property any FRTransService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - FRTransService
    serializable - true

    SystemSettings

    property any SystemSettings

    Attributes:
    access - public
    required - false
    returntype - any
    inject - SystemSettings
    serializable - true

    commandLocations

    property any commandLocations

    Attributes:
    access - public
    required - false
    returntype - any
    inject - commandLocations@constants
    serializable - true

    configured

    property boolean configured = [false]

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    consoleLogger

    property any consoleLogger

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:console
    serializable - true

    cr

    property any cr

    Attributes:
    access - public
    required - false
    returntype - any
    inject - cr@constants
    serializable - true

    fileSystemUtil

    property any fileSystemUtil

    Attributes:
    access - public
    required - false
    returntype - any
    inject - FileSystem
    serializable - true

    interceptorService

    property any interceptorService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - interceptorService
    serializable - true

    logger

    property any logger

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    metadataCache

    property any metadataCache

    Attributes:
    access - public
    required - false
    returntype - any
    inject - cachebox:metadataCache
    serializable - true

    parser

    property any parser

    Attributes:
    access - public
    required - false
    returntype - any
    inject - Parser
    serializable - true

    shell

    property any shell

    Attributes:
    access - public
    required - false
    returntype - any
    inject - Shell
    serializable - true

    stringDistance

    property any stringDistance

    Attributes:
    access - public
    required - false
    returntype - any
    inject - provider:StringSimilarity@string-similarity
    serializable - true

    system

    property any system

    Attributes:
    access - public
    required - false
    returntype - any
    inject - System@constants
    serializable - true

    wirebox

    property any wirebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    Method Detail

    addDefaultParameters

    private any addDefaultParameters([any commandString], [any parameterInfo])

    Merge in parameter defaults

    Parameters:
    commandString
    parameterInfo

    addToDictionary

    public any addToDictionary(any command, any commandPath)

    Parameters:
    command
    commandPath

    breakTokensIntoChain

    private any breakTokensIntoChain(array tokens)

    Takes 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' ] ]

    Parameters:
    tokens

    combineColonParams

    public any combineColonParams(struct parameters)

    Look through named parameters and combine any ones with a colon based on matching prefixes.

    Parameters:
    parameters

    configure

    public CommandService configure()

    Configure the service


    convertToNamedParameters

    public any convertToNamedParameters([any userPositionalParams], [any commandParams])

    Match positional parameters up with their names

    Parameters:
    userPositionalParams
    commandParams

    createCommandData

    private struct createCommandData(any fullCFCPath, any commandName)

    Create command metadata

    Parameters:
    fullCFCPath - the full CFC path
    commandName - the command name

    createGlobs

    private any createGlobs([any parameterInfo], [any commandParams])

    Check for Globber parameters and create actual Globber object out of them

    Parameters:
    parameterInfo
    commandParams

    ensureRequiredparams

    public any ensureRequiredparams([any userNamedParams], [any commandParams])

    Make sure we have all required params

    Parameters:
    userNamedParams
    commandParams

    evaluateExpressions

    public any evaluateExpressions(any parameterInfo)

    Evaluates any expressions as a command string and puts the output in its place.

    Parameters:
    parameterInfo

    evaluateSystemSettings

    public any evaluateSystemSettings(any parameterInfo)

    Evaluates any system settings and puts the output in its place.

    Parameters:
    parameterInfo

    generateListOfSimilarCommands

    public any generateListOfSimilarCommands(struct commandInfo)

    Generate a smart list of possible commands that the user meant to type

    Parameters:
    commandInfo

    getCallStack

    public array getCallStack()

    Get the array of commands being executed. This may be empty.


    getCommandHierarchy

    public any getCommandHierarchy()

    return the nested command structure


    getCommandLocations

    public string getCommandLocations()


    getCommands

    public any getCommands()

    return the command structure


    getConfigService

    public string getConfigService()


    getConfigured

    public string getConfigured()


    getConsoleLogger

    public string getConsoleLogger()


    getCr

    public string getCr()


    getFRTransService

    public string getFRTransService()


    getFileSystemUtil

    public string getFileSystemUtil()


    getInterceptorService

    public string getInterceptorService()


    getLogger

    public string getLogger()


    getMetadataCache

    public string getMetadataCache()


    getParser

    public string getParser()


    getShell

    public string getShell()


    getStringDistance

    public string getStringDistance()


    getSystem

    public string getSystem()


    getSystemSettings

    public string getSystemSettings()


    getWirebox

    public string getWirebox()


    inCommand

    public any inCommand([any command=''])

    Looks at the call stack to determine if we're currently "inside" a command. Useful to prevent endless recursion.

    Parameters:
    command - Name of the command to look for as typed from the shell. If empty, returns true for any command

    initCommands

    public CommandService initCommands(string baseCommandDirectory, string commandDirectory, [string commandPath=''])

    Initialize the commands. This will recursively call itself for subdirectories.

    Parameters:
    baseCommandDirectory - The starting directory
    commandDirectory - The current directory we've recursed into
    commandPath - The dot-delimted path so far-- only used when recursing

    isCommandCFC

    public any isCommandCFC(struct commandData)

    checks if given cfc name is a valid command component

    Parameters:
    commandData - the command metadata

    lazyLoadCommandCFC

    private any lazyLoadCommandCFC([any commandData])

    Takes a struct of command data and lazy loads the actual CFC isntance if neccessary

    Parameters:
    commandData - Struct created by registerCommand()

    listCommands

    public any listCommands()

    return a list of base commands


    mergeFlagParameters

    private any mergeFlagParameters(struct parameterInfo)

    Merge flags into named parameters

    Parameters:
    parameterInfo

    parseParameters

    public any parseParameters([any parameters], [any commandParameters])

    Take an array of parameters and parse them out as named or positional

    Parameters:
    parameters - The array of params to parse.
    commandParameters - valid params defined by the command

    registerCommand

    private any registerCommand([any baseCommandDirectory], [any CFC], [any commandPath])

    load command CFC

    Parameters:
    baseCommandDirectory - The base directory for this command
    CFC - CFC name that represents the command
    commandPath - The relative dot-delimted path to the CFC starting in the commands dir

    resolveCommand

    public any resolveCommand(string line, [boolean forCompletion='false'])

    Figure out what command to run based on the the user input string

    Parameters:
    line - A string containing the command and parameters that the user entered
    forCompletion

    resolveCommandTokens

    public any resolveCommandTokens(array tokens, [string rawLine='[runtime expression]'], [boolean forCompletion='false'])

    Figure out what command to run based on the tokenized user input

    Parameters:
    tokens - An array containing the command and parameters that the user entered
    rawLine
    forCompletion

    runCommand

    public any runCommand(array commandChain, string line, [string piped], [boolean captureOutput='false'])

    run a command

    Parameters:
    commandChain - the chain of commands to run
    line
    piped
    captureOutput - Temp workaround to allow capture of run command

    runCommandTokens

    public any runCommandTokens(array tokens, [string piped], [boolean captureOutput='false'])

    run a command tokens

    Parameters:
    tokens - tokens to run
    piped - Data to pipe in to the first command
    captureOutput - Temp workaround to allow capture of run command

    runCommandline

    public any runCommandline(string line, [boolean captureOutput='false'])

    run a command line

    Parameters:
    line - line to run
    captureOutput - Temp workaround to allow capture of run command

    setCommandLocations

    public any setCommandLocations(any commandLocations)

    Parameters:
    commandLocations

    setConfigService

    public any setConfigService(any ConfigService)

    Parameters:
    ConfigService

    setConfigured

    public any setConfigured(boolean configured)

    Parameters:
    configured

    setConsoleLogger

    public any setConsoleLogger(any consoleLogger)

    Parameters:
    consoleLogger

    setCr

    public any setCr(any cr)

    Parameters:
    cr

    setFRTransService

    public any setFRTransService(any FRTransService)

    Parameters:
    FRTransService

    setFileSystemUtil

    public any setFileSystemUtil(any fileSystemUtil)

    Parameters:
    fileSystemUtil

    setInterceptorService

    public any setInterceptorService(any interceptorService)

    Parameters:
    interceptorService

    setLogger

    public any setLogger(any logger)

    Parameters:
    logger

    setMetadataCache

    public any setMetadataCache(any metadataCache)

    Parameters:
    metadataCache

    setParser

    public any setParser(any parser)

    Parameters:
    parser

    setShell

    public any setShell(any shell)

    Parameters:
    shell

    setStringDistance

    public any setStringDistance(any stringDistance)

    Parameters:
    stringDistance

    setSystem

    public any setSystem(any system)

    Parameters:
    system

    setSystemSettings

    public any setSystemSettings(any SystemSettings)

    Parameters:
    SystemSettings

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    validateParams

    private any validateParams([any userNamedParams], [any commandParams])

    Make sure all params are the correct type

    Parameters:
    userNamedParams
    commandParams