| name | commandbox-usage |
| description | Use this skill for CommandBox CLI usage: running commands, namespaces, tab completion, system settings, environment variables, shell variables, piping, recipes, REPL, foreach loops, jq/sql/printtable commands, ad-hoc aliases, default parameters, exit codes, and interactive shell features. |
CommandBox CLI Usage
Overview
CommandBox is an interactive shell and script runner. Launch it with box (interactive) or run one-off commands with box <command>.
box
box version
box install coldbox
box server start
Commands & Namespaces
Commands are case-insensitive and organized into namespaces (multi-word groups):
version
upgrade
reload
server start
server stop
server list
package init
package set name="My App"
artifacts list
artifacts clean
config set
config show
testbox run
Get help for any namespace or command:
server help
server start help
package help
Parameters
server start port=8080 host=localhost
install coldbox
install coldbox --verbose
install coldbox --noSave
server start --noSaveSettings --noOpenBrowser
package set description="My great app"
config set myArray="['a','b','c']"
Default Command Parameters
command params set "server start" openBrowser=false
command params set "install" --verbose
command params show "server start"
command params clear "server start"
Escaping Special Characters
echo foo\=bar
echo \`notAnExpression\`
System Settings (Dynamic Placeholders)
System settings allow dynamic values from JVM properties and OS environment variables:
echo ${PATH}
echo ${HOME}
server start port=${SERVER_PORT:8080}
server set web.host=${SERVER_HOST:localhost}
Lookup order (first match wins):
- Per-command env vars
- Parent command env vars
- Global shell env vars
- JVM System Properties
- OS Environment Variables
In server.json and box.json:
{
"web": {
"http": {
"port": "${WEB_PORT:8080}"
}
}
}
echo ${server::web.http.port}
echo ${box::version}
echo ${config::name}
echo ${env::MY_VAR}
echo ${java::user.home}
Environment Variables (Shell)
set foo=bar
env set foo=bar
env show foo
echo ${foo}
echo ${foo:default}
env clear foo
env show
env debug
Per-command variables (scoped to that command only):
echo `set myVar=cheese && echo ${myVar}`
env show myVar myDefault
Expressions & Piping
echo `package show version`
package set version=`package show version`
package show dependencies | foreach "echo 'Package: ${item}'"
echo "coldbox" | install
install coldbox && server start
Recipes
Recipes are scripts of CommandBox commands run in a subshell:
echo "install coldbox"
echo "server start"
recipe myRecipe.boxr
echo "upgrade; version" | recipe
recipe "install coldbox; server start; testbox run"
Foreach (Looping)
foreach "foo,bar,baz" "echo 'Item: ${item}'"
package show dependencies | foreach "echo 'Dep: ${item}'"
foreach delimiter="|" "a|b|c" "echo ${item}"
foreach "a,b,c" "echo '${index}: ${item}'"
REPL (Interactive Evaluation)
repl
now()
createUUID()
x = 5; y = 10; x + y
exit
Helpful Commands
jq — JSON Query
package show | jq .name
server list --json | jq '.[].name'
config show | jq 'keys(@)'
sql — Query Tabular Data
server list --json | sql "select name, status from servers where status='running'"
printtable — Pretty Table Output
server list --json | printtable
package list --json | printtable --headers "name,version,description"
ask and confirm — Interactivity
set name=`ask "What is your name? "`
echo "Hello, ${name}!"
confirm "Delete all files?" && rm -rf ./build
checksums
checksum file=myfile.zip algorithm=sha256
token Replacements
tokenReplace path="./config.xml" token="@@version@@" replacement=`package show version`
Ad-Hoc Command Aliases
alias set ls="server list"
alias set gs="!git status"
ls
alias remove ls
alias show
Exit Codes
box server start && echo "Server started OK"
box testbox run || echo "Tests failed!"
if box testbox run; then
echo "All tests passed"
fi
Watch Command
watch command="testbox run" paths="**.cfc,**.cfm"
watch command="server restart" paths="server.json" delay=500
Auto-Update Checks
config set autoupdatecheck=false
upgrade
Bullet Train Prompt
The interactive shell supports a customizable prompt:
config set prompt.multiline=true
config set modules.commandbox-bullet-train.showGitBranch=true
256 Color Support
print.red( "Error message" )
print.boldGreenLine( "Success!" )
print.cyanLine( "Info" )
echo "Text"