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.
To see the settings used for formatting, use the
--settings flag. When that is present the
cfformat command will just dump to the console the settings it will use to format, 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
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||Download|
|0.7.0||May 06 2019 05:52 PM||May 06 2019 05:52 PM||John Berquist (jcberquist)|
|0.6.0||Apr 25 2019 10:52 AM||Apr 25 2019 10:52 AM||John Berquist (jcberquist)|
|0.5.0||Feb 21 2019 07:22 PM||Feb 21 2019 07:22 PM||John Berquist (jcberquist)|
|0.4.0||Feb 17 2019 02:34 PM||Feb 17 2019 02:34 PM||John Berquist (jcberquist)|
|0.3.1||Feb 07 2019 10:43 PM||Feb 07 2019 10:43 PM||John Berquist (jcberquist)|