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.
Blog
Using CommandBox to manage dependencies
Dependencies are other packages that are required by another package for it to run. A simple package may have no dependencies, or it may have many. There are two types of dependencies: a regular dependency or a development dependency. Regular dependencies are ones required for operation of the main package. Development dependencies are optional and only necessary if you plan on making changes to the package you're installing. Dev dependencies would include testing frameworks or build tools.
When a package is installed, CommandBox will read its dependencies (from the box.json) and recursively install them as well. This encourages developers to write small, reusable libraries for everyone to use. When installing via a package manager, you don't have to worry about getting all the pieces installed.
CommandBox Tips for the Command Line
Hopefully we have piqued your interesting into using CommandBox to help you with your day to day development, but maybe you haven't had much experience with a CLI. I wanted to share a few tips and tricks to make your life easier.
CommandBox - Choose your own Adventure
CommandBox’s run command is not like a normal function you write. Each piece of the function is run line by line, to give you that interactivity needed for a true command prompt application. To test this side of things, I decided I had 2 choices, build a wizard, or enter the room to the left. Wait a minute, the room to the left, that sounds like one of those Choose your own Adventure stories, where the choices you make, affect the outcome of the story. That’s right… remembering how cool those books were, I decided that would be more fun, so lets see how you can build your own “Choose your own Adventure” command for CommandBox.
CommandBox and URL Rewrites Made Easy
Once you start using the embedded server for your development projects, you may wish you enable URL rewriting. Rewrites are used by most popular frameworks to do things like add the index.cfm back into SES URLs.
You may be used to configuring URL rewrites in Apache or IIS, but rewrites are also possible in CommandBox's embedded server via a Tuckey servlet filter.
Attention: MessageBox is Now a Module
The beloved MessageBox plugin has been a staple of the ColdBox platform since the beginning. With ColdBox 4.0 it's still available, but if you don't need it, you have the freedom to leave it out.
<...Package Wizard
One of my personal favorites of CommandBox is the introduction of step-by-step wizards for some complication creation processes like a new package or a new ColdBox application. It will take you by the hand and never let you go :) Here is the way to initialize a new package with our nice wizard:. First let's go into our interactive shell by typing box
or opening the box binary.
Intro to box.json
In ForgeBox package management, the box.json file contains data related to your package. This post covers a good base for what minimum attributes to include to get your package loaded up to ForgeBox and make it CommandBox friendly.
ColdBox 4.0 Removed Plugins
ColdBox Plugins have graduated to become just models. The plugins convention has been removed and all references to plugin injection or DSL's are gone. You must now place all your plugins in your models directory and request them via getInstance() or getModel() calls.
Plugins are an old ColdBox convention but their baggage doesn't really serve a purpose now that we have modules for easy packaging of libraries and WireBox for easy creation of CFCs. Neither of those existed back when Plugins were birthed. It's time to say goodbye to the concept of plugins, but all their functionality will still be here, just with a slightly different (and more standardized) way of creating them.
CommandBox Embedded Server
One of the most useful features of CommandBox is the ability to start an ad-hoc server quickly and easily. Any folder on your hard drive can become the web root of a server. To start up the server, cd into a directory containing some CFML code, and run the start command. An available port will be chosen by default and in a few seconds, a browser window will open showing the default document (index.cfm).
CommandBox> cd C:\sites\test CommandBo...