commandbox.system.util

Class InteractiveJob

lucee.Component
    extended by commandbox.system.util.InteractiveJob

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I help update the user's console with progress for a curently executing (foreground) job in a nice and tidy way.

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano
  •  
    Property Summary
    type property default serializable required
    boolean active


    • access = public
    • returntype = any
    true false
    boolean dumpLog


    • access = public
    • returntype = any
    true false
    array jobs


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


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


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


    • access = public
    • returntype = any
    • inject = shell
    true false
    Constructor Summary
    init()
    Method Summary
    any addErrorLog(string line)
         Convenience method to log a red message.
    any addLog(string line, [string color=''])
         Add a line of logging.
    any addSuccessLog(string line)
         Convenience method to log a green message.
    any addWarnLog(string line)
         Convenience method to log a yellow message.
    any clear()
         Clear from the screen, but don't reset.
    any complete([boolean dumpLog='[runtime expression]'])
         Mark job as completed.
    any draw()
         Render the information to the console.
    any error([string message=''], [boolean dumpLog='[runtime expression]'])
         Mark job as Failed.
    any errorRemaining([any message=''])
         Cancel all remaining jobs and mark with error.
    private any finalizeOutput([boolean dumpLog])
         Outputs final representation of job to console for good.
    string getActive()
    private struct getCurrentJob()
         Get struct that represents the currently executing job.
    private numeric getCurrentJobDepth()
         Get number that represents the depth of the currently executing job.
    string getDumpLog()
    private string getJobTitle([any job])
         Returns colored and formatted job title.
    string getJobs()
    array getLines([any job], [any includeAllLogs='false'], [any finalOutput='false'])
         Returns array of AttribtuedString objects that represent this job and its children's current state.
    string getPrint()
    string getPrintBuffer()
    string getShell()
    boolean isActive()
         Is there an active job?.
    private struct newJob([any name], [any logSize])
         Returns empty struct of default job details.
    any onDIComplete()
    any reset()
         Reset the internal state of this job.
    any setActive(boolean active)
    any setDumpLog(boolean dumpLog)
    any setJobs(array jobs)
    any setPrint(any print)
    any setPrintBuffer(any printBuffer)
    any setShell(any shell)
    any start(string name, [any logSize='5'])
         Kick off a job.
    private string statusColor([any job])
         Returns name of color for current job status.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()


    Property Detail

    active

    property boolean active

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

    dumpLog

    property boolean dumpLog

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

    jobs

    property array jobs

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

    print

    property any print

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

    printBuffer

    property any printBuffer

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

    shell

    property any shell

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

    Method Detail

    addErrorLog

    public any addErrorLog(string line)

    Convenience method to log a red message

    Parameters:
    line - Message to log

    addLog

    public any addLog(string line, [string color=''])

    Add a line of logging. Feel free to use ANSI formatting

    Parameters:
    line - Message to log
    color

    addSuccessLog

    public any addSuccessLog(string line)

    Convenience method to log a green message

    Parameters:
    line - Message to log

    addWarnLog

    public any addWarnLog(string line)

    Convenience method to log a yellow message

    Parameters:
    line - Message to log

    clear

    public any clear()

    Clear from the screen, but don't reset


    complete

    public any complete([boolean dumpLog='[runtime expression]'])

    Mark job as completed. This will print out any final permanent lines and clear the state

    Parameters:
    dumpLog - Dump out all internal log lines permenantly to the console

    draw

    public any draw()

    Render the information to the console


    error

    public any error([string message=''], [boolean dumpLog='[runtime expression]'])

    Mark job as Failed. This will print out any final permanent lines and clear the state

    Parameters:
    message
    dumpLog - Dump out all internal log lines permenantly to the console

    errorRemaining

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

    Cancel all remaining jobs and mark with error

    Parameters:
    message - Error message to be applied to the current job

    finalizeOutput

    private any finalizeOutput([boolean dumpLog])

    Outputs final representation of job to console for good Resets the internal state this CFC so all job data is gone and there is no active job.

    Parameters:
    dumpLog - Include all log messages in output regardless of logSize

    getActive

    public string getActive()


    getCurrentJob

    private struct getCurrentJob()

    Get struct that represents the currently executing job.


    getCurrentJobDepth

    private numeric getCurrentJobDepth()

    Get number that represents the depth of the currently executing job.


    getDumpLog

    public string getDumpLog()


    getJobTitle

    private string getJobTitle([any job])

    Returns colored and formatted job title

    Parameters:
    job - Job struct to use

    getJobs

    public string getJobs()


    getLines

    public array getLines([any job], [any includeAllLogs='false'], [any finalOutput='false'])

    Returns array of AttribtuedString objects that represent this job and its children's current state

    Parameters:
    job - Reference to a job struct so this method can be called recursively
    includeAllLogs - Ignore logSize and include all log lines
    finalOutput - True if getting final output at the completion of the job.

    getPrint

    public string getPrint()


    getPrintBuffer

    public string getPrintBuffer()


    getShell

    public string getShell()


    isActive

    public boolean isActive()

    Is there an active job?


    newJob

    private struct newJob([any name], [any logSize])

    Returns empty struct of default job details

    Parameters:
    name - Name of job
    logSize - Size of the log to display

    onDIComplete

    public any onDIComplete()


    reset

    public any reset()

    Reset the internal state of this job


    setActive

    public any setActive(boolean active)

    Parameters:
    active

    setDumpLog

    public any setDumpLog(boolean dumpLog)

    Parameters:
    dumpLog

    setJobs

    public any setJobs(array jobs)

    Parameters:
    jobs

    setPrint

    public any setPrint(any print)

    Parameters:
    print

    setPrintBuffer

    public any setPrintBuffer(any printBuffer)

    Parameters:
    printBuffer

    setShell

    public any setShell(any shell)

    Parameters:
    shell

    start

    public any start(string name, [any logSize='5'])

    Kick off a job. Clears any previous state and starts drawing

    Parameters:
    name - Name of the job
    logSize

    statusColor

    private string statusColor([any job])

    Returns name of color for current job status

    Parameters:
    job - Job struct to use