commandbox.system

Class BaseCommand

lucee.Component
    extended by commandbox.system.BaseCommand
Direct Known Subclasses:
BaseTask

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I am the base command implementation. An abstract class if you will.

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


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


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


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


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


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


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


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


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


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


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


    • access = public
    • returntype = any
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    string ask([any message], [string mask=''], [string defaultResponse=''], [any keepHistory='false'], [any highlight='true'], [any complete='false'])
         ask the user a question and wait for response.
    any checkInterrupted([any thisThread='[runtime expression]'])
         Call this method periodically in a long-running task to check and see.
    any classLoad([any paths])
    any command(any name)
         Run another command by DSL.
    any confirm(any message)
         Ask the user a question looking for a yes/no response.
    any error(any message, [any detail=''], [any clearPrintBuffer='false'], [any exitCode='1'])
         Use if if your command wants to give controlled feedback to the user without raising.
    string getCR()
    any getCWD()
    any getEnv(string key, [any defaultValue])
         Retrieve an env value by name.
    any getExitCode()
    string getFileSystemUtil()
    string getFormatterUtil()
    any getInstance([any name], [any dsl], [any initArguments='[runtime expression]'], [any targetObject=''])
    string getJob()
    string getLogger()
    string getParser()
    string getPrint()
    any getPrinter()
    any getResult()
    string getShell()
    any getSystemProperty(string key, [any defaultValue])
         Retrieve a Java System property by name.
    any getSystemSetting(string key, [any defaultValue])
         Retrieve a Java System property or env value by name.
    string getSystemSettings()
    string getWirebox()
    any globber([any pattern=''])
         Return a new globber.
    any hasError()
         Tells you if the error() method has been called on this command.
    any multiSelect()
         Let a user choose between several options.
    any openPath([any path])
         This will open a file or folder externally in the default editor for the user.
    any openURL([any theURL])
         This will open a URL in the user's browser.
    any propertyFile([any propertyFilePath=''])
         Return a new PropertyFile instance.
    any reset()
    any resolvePath(string path, [any basePath='[runtime expression]'])
         This resolves an absolute or relative path using the rules of the operating system and CLI.
    any run()
    any runCommand(any command, [any returnOutput='false'])
         Run another command by name.
    any setCR(any CR)
    any setExitCode(numeric exitCode)
    any setFileSystemUtil(any fileSystemUtil)
    any setFormatterUtil(any formatterUtil)
    any setJob(any job)
    any setLogger(any logger)
    any setParser(any parser)
    any setPrint(any print)
    any setShell(any shell)
    any setSystemSettings(any SystemSettings)
    any setWirebox(any wirebox)
    any waitForKey([any message=''])
         Wait until the user's next keystroke.
    any watch()
         Create a directory watcher.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    CR

    property any CR

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

    exitCode

    property any exitCode

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

    fileSystemUtil

    property any fileSystemUtil

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

    formatterUtil

    property any formatterUtil

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

    job

    property any job

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

    logger

    property any logger

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

    parser

    property any parser

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

    print

    property any print

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

    shell

    property any shell

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

    SystemSettings

    property any SystemSettings

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

    wirebox

    property any wirebox

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

    Method Detail

    ask

    public string ask([any message], [string mask=''], [string defaultResponse=''], [any keepHistory='false'], [any highlight='true'], [any complete='false'])

    ask the user a question and wait for response

    Parameters:
    message - message to prompt the user with
    mask - When not empty, keyboard input is masked as that character
    defaultResponse
    keepHistory
    highlight
    complete
    Returns:
    the response from the user

    checkInterrupted

    public any checkInterrupted([any thisThread='[runtime expression]'])

    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

    Parameters:
    thisThread

    classLoad

    public any classLoad([any paths])

    Parameters:
    paths

    command

    public any command(any name)

    Run another command by DSL.

    Parameters:
    name - The name of the command to run.

    confirm

    public any confirm(any message)

    Ask the user a question looking for a yes/no response Accepts any boolean value, or "y".

    Parameters:
    message - The message to display to the user such as "Would you like to continue?"

    error

    public any error(any message, [any detail=''], [any clearPrintBuffer='false'], [any exitCode='1'])

    Use if if your command wants to give controlled feedback to the user without raising an actual exception which comes with a messy stack trace. Use clearPrintBuffer to wipe out any output accrued in the print buffer. return error( "We're sorry, but happy hour ended 20 minutes ago." );

    Parameters:
    message - The error message to display
    detail
    clearPrintBuffer - Wipe out the print buffer or not, it does not by default
    exitCode

    getCR

    public string getCR()


    getCWD

    public any getCWD()


    getEnv

    public any getEnv(string key, [any defaultValue])

    Retrieve an env value by name.

    Parameters:
    key - The name of the setting to look up.
    defaultValue - The default value to use if the key does not exist in the env

    getExitCode

    public any getExitCode()


    getFileSystemUtil

    public string getFileSystemUtil()


    getFormatterUtil

    public string getFormatterUtil()


    getInstance

    public any getInstance([any name], [any dsl], [any initArguments='[runtime expression]'], [any targetObject=''])

    Parameters:
    name
    dsl
    initArguments
    targetObject

    getJob

    public string getJob()


    getLogger

    public string getLogger()


    getParser

    public string getParser()


    getPrint

    public string getPrint()


    getPrinter

    public any getPrinter()


    getResult

    public any getResult()


    getShell

    public string getShell()


    getSystemProperty

    public any getSystemProperty(string key, [any defaultValue])

    Retrieve a Java System property by name.

    Parameters:
    key - The name of the setting to look up.
    defaultValue - The default value to use if the key does not exist in the system properties

    getSystemSetting

    public any getSystemSetting(string key, [any defaultValue])

    Retrieve a Java System property or env value by name.

    Parameters:
    key - The name of the setting to look up.
    defaultValue - The default value to use if the key does not exist in the system properties

    getSystemSettings

    public string getSystemSettings()


    getWirebox

    public string getWirebox()


    globber

    public any globber([any pattern=''])

    Return a new globber

    Parameters:
    pattern

    hasError

    public any hasError()

    Tells you if the error() method has been called on this command.


    multiSelect

    public any multiSelect()

    Let a user choose between several options. Can be set to multiselect, which returns array of selections multiSelect().setQuestion( 'Please Choose: ' ).setOptions( 'one,two,three' ).ask()


    openPath

    public any openPath([any path])

    This will open a file or folder externally in the default editor for the user. Useful for opening a new file for editing that was just created.

    Parameters:
    path

    openURL

    public any openURL([any theURL])

    This will open a URL in the user's browser

    Parameters:
    theURL

    propertyFile

    public any propertyFile([any propertyFilePath=''])

    Return a new PropertyFile instance

    Parameters:
    propertyFilePath

    reset

    public any reset()


    resolvePath

    public any resolvePath(string path, [any basePath='[runtime expression]'])

    This resolves an absolute or relative path using the rules of the operating system and CLI. It doesn't follow CF mappings and will also always return a trailing slash if pointing to an existing directory. Resolve the incoming path from the file system

    Parameters:
    path - The directory to resolve
    basePath - An expanded base path to resolve the path against. Defaults to CWD.

    run

    public any run()


    runCommand

    public any runCommand(any command, [any returnOutput='false'])

    Run another command by name. This is deprecated in favor of command(), which escapes parameters for you.

    Parameters:
    command - The command to run. Pass the same string a user would type at the shell.
    returnOutput

    setCR

    public any setCR(any CR)

    Parameters:
    CR

    setExitCode

    public any setExitCode(numeric exitCode)

    Parameters:
    exitCode

    setFileSystemUtil

    public any setFileSystemUtil(any fileSystemUtil)

    Parameters:
    fileSystemUtil

    setFormatterUtil

    public any setFormatterUtil(any formatterUtil)

    Parameters:
    formatterUtil

    setJob

    public any setJob(any job)

    Parameters:
    job

    setLogger

    public any setLogger(any logger)

    Parameters:
    logger

    setParser

    public any setParser(any parser)

    Parameters:
    parser

    setPrint

    public any setPrint(any print)

    Parameters:
    print

    setShell

    public any setShell(any shell)

    Parameters:
    shell

    setSystemSettings

    public any setSystemSettings(any SystemSettings)

    Parameters:
    SystemSettings

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    waitForKey

    public any waitForKey([any message=''])

    Wait until the user's next keystroke

    Parameters:
    message - Message to display to the user such as "Press any key to continue."

    watch

    public any watch()

    Create a directory watcher. Call its DSL to configure it.