FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...
This module registers a
cfformat command in CommandBox that can be used to format CFML components. It is called with a path directly to a component, or a path to a directory. When a directory is passed, that directory is crawled for component files, and every component found is formatted.
cfformat ./models/MyComponent.cfc cfformat ./models/
If it is passed a component path it will, by default, print the formatted component text to the console. You can redirect this output to a new file if you wish. Alternatively you can use the
--overwrite flag to overwrite the component in place instead of printing to the console.
When passed a directory,
cfformat always overwrites component files in place, and so it will ask for confirmation before proceeding. Here you can use the
--overwrite flag to skip this confirmation check.
cfformat can also be called with a directory path and the
--watch flag. When this is done,
cfformat will use CommandBox's built in support for file watching to watch that directory for component changes, and will perform formatting passes on those files.
cfformat ./ --watch
To see the settings used for formatting, use the
--settings flag. When that is present the
cfformat command will just dump the settings it will use to format to the console, and not perform any formatting:
cfformat --settings # or cfformat /some/path --settings # or cfformat path/to/my.cfc /path/to/.cfformat.json --settings
The following order is used to resolve the settings used for formatting:
.cfformat.jsonfile in your home directory
.cfformat.jsonfile found in the directory where formatting will be performed, or a parent directory thereof. Parent directories will be searched for a
.cfformat.jsonfile recursively until one is found or the root directory is reached. If a folder contains a
.gitdirectory that will also halt the search.
These settings will be merged together starting with the base settings and then merging each level on top.
If you want to place a settings file in a directory other than your home directory (for number 2 above) you can set the
cfformat.settings config setting to a different path:
config set cfformat.settings=/path/to/.cfformat.json
Specifying a settings file to use inline when running
cfformat is done as follows:
cfformat path/to/my.cfc /path/to/.cfformat.json
For more information on the settings used and what they do please see the reference. You can also print reference information to the console using the
settingInfo can be passed either a full setting name, or just a prefix:
cfformat settingInfo=array.padding cfformat settingInfo=array
Behind the scenes,
cfformat makes use of the syntect library along with syntax files from Sublime Text's Packages repository to create an executable that uses the CFML syntax for Sublime Text to generate syntax scopes for component files.
cfformat attempts to download this executable from GitHub when installed, or when it is updated (if necessary). If it is unable to download the executable, it should print a message to the console prompting you to download from GitHub, and indicating where to put it. If you have Rust installed, you can also build the executable yourself by running the
build.cfc task runner in the root of this repository:
task run build.cfc
Here are all the versions for this package. Please note that you can leverage CommandBox package versioning to install any package you like. Please refer to our managing package version guide for more information.
|Version||Created||Last Update||Published By||Stable||Actions|
|0.8.0||May 31 2019 01:56 PM||May 31 2019 01:56 PM|
|0.7.0||May 06 2019 05:52 PM||May 06 2019 05:52 PM|
|0.6.0||Apr 25 2019 10:52 AM||Apr 25 2019 10:52 AM|
|0.5.0||Feb 21 2019 07:22 PM||Feb 21 2019 07:22 PM|
|0.4.0||Feb 17 2019 02:34 PM||Feb 17 2019 02:34 PM|
|0.3.1||Feb 07 2019 10:43 PM||Feb 07 2019 10:43 PM|