Blog

CommandBox - Mastering Parameters

Brad Wood March 06, 2015

Spread the word

Brad Wood

March 06, 2015

Spread the word


Share your thoughts

CommandBox is unique from other CLIs in a couple ways.  My favorite one is that everything is built around the concept of commands.  Not only does this organize how CFML scripts can be run from the command line, it also greatly simplifies writing custom commands since you have a platform to build upon.  Part of that platform is automatic parameter handling, which brings me to my second favorite thing about CommandBox.  Many CLIs only allow for positional parameters, while CommandBox also allows for the familiar syntax of named parameters plus the convenience of flags for quick boolean controls.

Named

coldbox create app name=myApp skeleton=AdvancedScript directory=myDir init=true

Positional

coldbox create app myApp AdvancedScript myDir true

Flags

coldbox create app myApp --init --installColdBox

Here's some cool tricks to mastering the command line like a pro with CommandBox.

Escaping Special Characters

If a value is a single word with no special characters, you don't need to escape anything. Certain characters are reserved as special characters though for parameters since they demarcate the beginning and end of the actual parameter and you'll need to escape them properly. These rules apply the same to named and positional parameters.

Spaces

If a parameter has any white space in it, you'll need to wrap the value in single or double quotes. It doesn't matter which kind you use and it can vary from one parameter to another as long as they match properly.

echo 'Hello World'
echo "Good Morning Vietnam"


Quotes

Quotes are actually allowed unescaped in a value like so:

echo O'reilly


However, if the parameter contains whitespace and is surrounded by quotes, you'll need to escape them with a backslash.

echo 'O\'reilly Auto Parts'
echo "Luis \"The Dev\" Majano"


Only like quotes need to be escaped. Single quotes can exist inside of double and vice versa without issue. These examples below are perfectly valid.

echo "O'reilly Auto Parts"
echo 'Luis "The Dev" Majano'


Equals Signs

If you have an equals sign in your value, you'll need to escape it with a backlash.

echo 2+2\=4


Line Breaks

A new line can be specified with the text \n. Keep in mind, some parameters might not expect new lines to exist and could error.

package set description="first line\nSecond Line\nThird Line"


Backslash

Since the backslash is used as our escape character you'll need to escape any legitimate backslash that happens to precede a single quote, double quote, equals sign, or letter n.

echo foo\\\=bar
This will print foo\=bar

File Paths

Many Commands accept a path to a folder or file on your hard drive. You can specify a fully qualified path that starts at your drive root, or a relative path that starts in your current working directory. To find your current working directory, use the pwd command (Print Working Directory). To change your current working directory, use the cd command.

Here is a fully qualified path in Windows and Unix-based:

mkdir C:\sites\test
mkdir \opt\var\sites\test


For a relative path, do not begin with a slash.

mkdir test


File system paths will be canonicalized automatically which means the following is also valid:

mkdir ../../sites/test

 

Add Your Comment

Recent Entries

CBWire: The Smart Path to Modern, Reactive CFML Applications!

CBWire: The Smart Path to Modern, Reactive CFML Applications!

That’s where CBWire comes in — a powerful ColdBox module designed specifically to help companies modernize their CFML applications by enabling reactive, dynamic user interfaces without a complete overhaul or the need for heavy front-end tooling.

Maria Jose Herrera
Maria Jose Herrera
July 25, 2025
Call for Speakers: Into the Box 2026!

Call for Speakers: Into the Box 2026!

The future of web development is now, and Into the Box 2026 is leading the charge! We’re calling on developers, architects, and tech trailblazers from around the world to step on stage, share your knowledge, and shape the future of modern development with us.

Maria Jose Herrera
Maria Jose Herrera
July 23, 2025
Into the Box 2026 is Here: Learn all the details!

Into the Box 2026 is Here: Learn all the details!

We're back and bolder than ever. Into the Box 2026 is officially open for early registration, and we’re inviting you to be part of our mission to modernize the world of BoxLang, CFML, and Java development. This year’s theme, Modernization in Motion:Building a Dynamic Future, is more than a saying, it’s a call to action. As the tech landscape evolves, developers need tools that offer agility, scalability, and the freedom to grow. That’s exactly what we’re delivering across the Ortus Ecosystem.

With BoxLang, ColdBox, CommandBox, TestBox, and more, you can modernize on your own terms, quickly, flexibly, and backed by a growing community.

Maria Jose Herrera
Maria Jose Herrera
July 17, 2025