arrow-left

All pages
gitbookPowered by GitBook
1 of 7

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Module Lifecycle

hashtag
preModuleLoad

Announced before each module that is loaded.

interceptData

  • moduleLocation - Path to the module

  • moduleName - Name of the module

hashtag
postModuleLoad

Announced after each module that is loaded.

interceptData

  • moduleLocation - Path to the module

  • moduleName - Name of the module

  • moduleConfig

hashtag
preModuleUnLoad

Announced before each module that is unloaded.

interceptData

  • moduleName - Name of the module

hashtag
postModuleUnload

Announced after each module that is unloaded.

interceptData

  • moduleName - Name of the module

Core Interception Points

Here is a list of all the core interception points in CommandBox that you can listen to. Some have interceptData that comes along with them, while others don't. Remember, the interceptData struct is passed by reference. This means modifying any values directly in that struct will affect how processing continues afterwards inside of CommandBox where those values are used.

Click a category for more information.

- Struct representing the configuration data for the module.

onCLIStart

  • onCLIExit

  • Command Execution Lifecycle

    • preCommand

    • postCommand

  • Module Lifecycle

    • preModuleLoad

    • postModuleLoad

    • preModuleUnLoad

    • postModuleUnload

  • Server Lifecycle

    • preServerStart

    • onServerStart

    • onServerInstall

    • onServerStop

  • Error Handling

    • onException

  • Package Lifecycle

    • preInstall

    • onInstall

    • postInstall

    • preUninstall

    • postUninstall

    • preVersion

    • postVersion

    • prePublish

    • postPublish

    • preUnpublish

    • postUnpublish

    • onRelease

  • CLI Lifecycle

    CLI Lifecycle

    hashtag
    onCLIStart

    Announced when shell first starts, but before any commands are run or output has been flushed to the console.

    interceptData

    • shellType - The string interactive if starting the interactive shell, or command if running a one-off command and exiting

    • args - An array of arguments provided from the OS when box was executed.

    • banner - A string containing the CommandBox banner text that displays when in interactive mode.

    This fires every time the reload command runs and a fresh shell is created.

    hashtag
    onCLIExit

    Announced right before the shell exits and control is returned back to the OS. This fires every time the reload command runs right before the shell is destroyed and re-created.

    Error Handling

    hashtag
    onException

    Announced any time an unhandled exception is thrown.

    interceptData

    • exception - Error struct

    Command Execution Lifecycle

    hashtag
    preCommand

    Announced before the execution of a command. This fires after all command parameters have been evaluated, including expressions. If piping the output of one command into another in a command chain, this will fire twice-- once for each command in the chain.

    interceptData

    • commandInfo - A struct containing the following keys about the command to execute

      • commandString - A string representing the command name

      • commandReference - The instantiated Command CFC

      • parameters

    • parameterInfo - A struct containing the following keys about the processed parameters for the command execution

      • positionalParameters - An array of parameter values

      • namedParameters

    hashtag
    postCommand

    Announced immediately after command execution is complete. If more than one command is piped together in a command chain, this is announced after each command in the chain.

    interceptData

    • commandInfo - Same as preCommand above

    • parameterInfo - Same as preCommand above

    hashtag
    prePrompt

    Announced prior to drawing the prompt in the interactive shell. This interception point can be used to customize the text of the prompt by modifying the prompt variable in intercept data which is an ANSI-formatted string to be output before the cursor.

    interceptData

    • prompt - An ANSI-formatted string containing the prompt text. Replacing this value will override the prompt.

    hashtag
    preProcessLine

    Pre and post command fire before and after each command, but that means they fire twice for something like:

    preProcessLine will fire only once for the above command after the user hits enter but before anything is processed.

    interceptData

    • line - A string representing the line typed into the shell. Changing the contents of this string will override what actually gets executed.

    hashtag
    postProcessLine

    Pre and post command fire before and after each command, but that means they fire twice for something like:

    postProcessLine will fire only once for the above command after the entire line has been executed. Any output is already sent to the console by the time this interception point fires.

    interceptData

    • line - A string representing the line that was just executed in the shell.

    - An array of un-parsed parameter tokens typed in the CLI
  • closestHelpCommand - The CFC path to the most-applicable help command. Used to generate namespace help.

  • - A struct of name/value pairs. The named parameters are always what is passed to the command's
    run()
    method.
  • flags - A struct of flags that were passed in.

  • results - A string that represents any output from the command that hasn't already been flushed to the console.
    echo `package show name`
    echo `package show name`

    Server Lifecycle

    hashtag
    preServerStart

    Announced before a server starts. This fires after server.json has been located but before any configuration is resolved. Use this to override any user inputs, influence how the server's details are resolved, or to modify things like hostname before ports are bound.

    interceptData

    • serverDetails - A struct with the following keys used in starting the server

      • defaultName - The name of the server

      • defaultwebroot - The web root of the server

    • serverProps - A struct with the parameters passed to the start command from the CLI. Omitted params will not be present.

      • See the help for the server start command to see the current list of parameters.

    hashtag
    onServerStart

    Announced as a server is starting after the configuration values have been resolved, but prior to the actual server starts. Use this to modify the settings for the server before it starts.

    interceptData

    • serverInfo - A struct with the following keys used in starting the server

      • name - The name of the server

    hashtag
    onServerInstall

    Announced when a server is starting and the cfengine is being installed. This gives you a chance to influence how the server is installed or to modify default settings before the server process actually starts. This is not announced for servers using a WARPath setting. It is announced every time a server is started, but you can use the installDetails.initialInstall flag to determine if this is the first time the engine is being installed for one-time tasks.

    interceptData

    • serverInfo - Same as onServerStart above

    • installDetails A struct with the following keys:

    hashtag
    onServerStop

    Announced before a server stop.

    interceptData

    • serverInfo - Same as onServerStart above

    hashtag
    preServerForget

    Always fires before attempting to forget a server whether or not the forgetting is actually successful. Has access to all files and settings for the server.

    interceptData

    • serverInfo - Same as onServerStart above

    hashtag
    postServerForget

    Fires after a successful server forget. If the forget fails, this will not fire.

    interceptData

    • serverInfo - Same as onServerStart above

    defaultServerConfigFile - The location of the server.json (May not exist yet)

  • serverJSON - The parsed contents of the JSON file

  • serverInfo - The serverInfo Struct (see below)

  • serverIsNew - A boolean whether this server has been started before.

  • webroot
    - The path to the web root
  • serverConfigFile - The path to the server.json file (may not exist)

  • trayEnable - If tray menu is enabled

  • customServerFolder - Where the server's log files live. May be the same as serverHomeDirectory

  • debug - Whether to start Runwar in debug mode

  • trace - Whether to start Runwar in trace mode

  • console - Whether to start server in console mode

  • openbrowser - Flag to open web browser upon start

  • host - The hostname to bind the server to

  • port - The HTTP port

  • stopsocket - The socket to listen for stop connections

  • webConfigDir - Path to the Lucee web context

  • serverConfigDir - Path to the Lucee server context

  • libDirs - List of additional lib paths

  • trayEnable - If tray menu is enabled

  • trayIcon - Path to .png file for tray icon

  • trayOptions - Array of tray menu options

  • webXML - Path to web.com file

  • SSLEnable - Enable HTTPS flag

  • HTTPEnable - Enable HTTP flag

  • SSLPort - HTTPS port

  • SSLCert - SSL Certificate

  • SSLKey -SSL Key

  • SSLKeyPass - SSL Key passphrase

  • rewritesEnable - Enable URL rewrites

  • rewritesConfig - Path to custom Tuckey rewrite config file

  • heapSize - Max heap size in Megabytes

  • directoryBrowsing - Enable directory browsing

  • JVMargs - Additional JVM args to use when starting the server

  • runwarArgs - Additional Runwar options to use when starting the server

  • logdir - Path to directory for server logs

  • welcomeFiles - List of welcome files

  • serverDetails - Same as onServerStart above

  • installDetails - Same as onInstall below

  • internal - True if using the embedded jars from the CLI
  • enginename - The name of the cfengine that was installed

  • version - The version of the cfengine that was installed

  • installDir - The folder where the server is installed to

  • initialInstall - True if this is the first time the engine was installed

  • Package Lifecycle

    hashtag
    preInstall

    Announced prior to installing a package. If a package has additional dependencies to install, each of them will fire this interception point.

    interceptData

    • installArgs - Struct containing the following keys used in installation of the package.

      • ID - The ID of the package to install

      • directory - Directory to install to. May be null, if none supplied.

      • save

    hashtag
    onInstall

    Announced while a package is being installed, after the package endpoint and installation directory has been resolved but before the actual installation occurs. This allows you to override things like the installation directory based on package type. Any values updated in the interceptData struct will override what the install command uses.

    interceptData

    • installArgs - Same as preInstall above

    • installDirectory - Directory that the package will be installed in

    hashtag
    postInstall

    Announced after an installation is complete. If a package has additional dependencies to install, each of them will fire this interception point.

    interceptData

    • installArgs - Same as preInstall above

    hashtag
    preUninstall

    Announced before the uninstallation of a package.

    interceptData

    • uninstallArgs - Struct containing the following keys used in removal of the package

      • ID - ID of the package to uninstall

    hashtag
    postUninstall

    Announced after the uninstallation of a package.

    interceptData

    • uninstallArgs - Same as preUninstall above

    hashtag
    preVersion

    Announced before the new version is set in the package.

    interceptData

    • versionArgs - A struct containing the following keys:

      • version - The new version about to be set

    hashtag
    postVersion

    Announced after the new version is set in the package but before the Git repo is tagged.

    interceptData

    • versionArgs - Same as preVersion above.

    hashtag
    onRelease

    Announced after a new version is set using the bump command and after the Git repo is tagged.

    interceptData

    • directory - The working directory of the package

    • version - The new version about was set

    hashtag
    prePublish

    Announced prior to publishing a package to an endpoint

    interceptData

    • publishArgs - A struct containing the following keys:

      • endpointName - The name of the endpoint being published to

    hashtag
    postPublish

    Announced after publishing a package to an endpoint

    interceptData

    • publishArgs - Same as prePublish above.

    • boxJSON - Same as prePublish above.

    Announced prior to unpublishing a package from an endpoint

    interceptData

    • unpublishArgs - A struct containing the following keys:

      • endpointName - The name of the endpoint being published to

    hashtag
    postUnpublish

    Announced after unpublishing a package from an endpoint

    interceptData

    • unpublishArgs - Same as preUnpublish above.

    • boxJSON - Same as preUnpublish above.

    - Flag to save box.json dependency
  • saveDev - Flag to save box.json dev dependency

  • production - Flag to perform a production install

  • currentWorkingDirectory - Original working directory that requested installation

  • verbose - Flag to print verbose output

  • force - Flag to force installation

  • packagePathRequestingInstallation - Path to package requesting installing. This climbs the folders structure for nested dependencies.

  • containerBoxJSON
    - A struct containing the
    box.json
    of the page requesting the installation
  • artifactDescriptor - A struct containing the box.json of the package artifcat about to be installed

  • artifactPath - The folder containing the unzipped artifact, ready to be installed.

  • ignorePatterns - An array of file globbing patterns to ignore on installation

  • endpointData - A struct containing the following keys.

    • endpointName - The name of the endpoint. i.e. "forgebox" or "HTTP"

    • package - The name of the package. i.e. "cborm" or "coldbox"

    • ID - The canonical ID of the endpoint. i.e. "forgebox:coldbox" or "github:user/repo"

    • endpoint - The instance of the endpoint CFC that implements IEndpoint.

  • directory
    - The directory to be uninstalled from (used to find box.json)
  • save - Whether to update box.json

  • currentWorkingDirectory - Path to package requesting removal . This climbs the folders structure for nested dependencies.

  • tagVersion
    - Boolean that determines whether to tag a Git repo
  • message - Commit message to use when tagging Git repo

  • directory - The working directory of the package

  • force - If true, tag a Git repo even if it isn't clean

  • directory
    - The directory that the package lives in
  • boxJSON - A struct containing the defaulted box.json properties for the package

  • preUnpublish
    directory
    - The directory that the package lives in
  • version - The version being unpublished

  • force - Boolean to skip the interactive prompt

  • boxJSON - A struct containing the defaulted box.json properties for the package