CF Camp Notes: Command Box, Luis Majano

October 20, 2014

CF Camp Notes: Command Box, Luis Majano

How do we work in CF?
we look in folders, on the web, etc, for pieces of code.
so we have all these pieces of code from various places
not a lot of order, not a lot of package management / tooling

(Book: Core J2EE Patterns)

What is CommandBox --
CLI abstraction
package manager
REPL tool (read eval print loop)
Integrated server
ForgeBox
extensible via ColdFusion ( don't have to know java)
Scaffolding
Automation
etc

this is not *Box only. works for EVERY CF developer

Installation
works for every OS -- win, mac, linux
33 megs
Java 1.7+
still in beta, first release in the next week

it's professional open source. you can contribute if you want

CLI --
ability to execute CFML code
also created an interactive shell ala Grails or Ruby
Usage - OS Execution
Execute CFML Files:
box my app.cfm &
(& runs it in the background, as a background process)

box scripting: *unix
#!/usr/bin/env box
can create shell scripts in CF!

Enhanced Execution
box execute myapp.cfm name=luis

everything is done thru "commands"
that's how you get things done

Commands are separated by namespaces, you can create your own namespaces as well.

Output piping "|"
File redirection ">"
just like other command line tools!

Package Manager --

box.json
package descriptor
declares package metadata
-name, slug, version, author, dependencies, devdependencies, installation details, custom meta data

Where do they come from?
ForgeBox
file zip/tar
directory
git
svn
github
other places too

ForgeBox
Cloud package repo
web gui
community driven
145+ packages

REPL --
Read-Eval Print-Loop
execute code while you're typing it
so from a command line:
a = 3
writeOutput( now() );
...at the command line and the code executes

type "repl" at Commandbox prompt and your'e in "REPL mode"

Integrated Server --
to take the pain away from setting up a CF server.
integrated w/ Undertow -- full servlet container
keeps track of servers, no WEB-INF needed
server - start, stop, restart, status, etc,
right now only works on Railo but working on CF10 and 11 support for later.

Scaffolding --
example:
init
coldbox create app "myapp" --installColdBoxBE
etc

just build a script to completely scaffold out an app, with dependencies, testing, etc.


Automation --
run - execute any OS binary
- integrate with grunt/gulp/ant

execute
-enhanced execution
-can accept parameters

recipe
-like a "batch" file !#/usr/bin/box
runs multiple commands
can accept parameters
my.recipe.boxr
"boxr" extension
can execute boxr from the OS
will have "handles" soon
-- so you can double-click in your OS and execute it that way too

.boxr file contents:
mkdir $1 (positional params just like in an OS)
cd $1
init $1
run git init
touch .gitignore

#create a codebox app
coldbox create app $1 --installColdBoxBE
cold box create handler contacts index,save,delete
etc

then at command line: "recipe my-recipe.boxr MyAppName"

Everything is built via WireBox. That's the "bootstrapper" behind all of this.

To search for new commands:
forge box search norris
finds any commands that include the term "norris" (i.e. the Chuck Norris command)

Roadmap --
next portion is "task runners"
bring Ant / Grunt type power to CF
Adobe CF Engine integration
ForgeBox 2.0 (in a couple weeks)
ForgeBox Enterprise -- for companies that don't want to put things in a public repo. can have it on your own "institution"
More Generators
Automation / Async

Can download it now via ortussolutions.com/products/commandbox

there's a google group and training/support available as well