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.
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...
CommandBox is a whole system in itself, and when developing for CommandBox, like you would other applications, debugging is important. By default if you have any errors in your code, CommandBox outputs the error message, and a stack trace to the user in the console… and they will be returned to the prompt. This is great for you as a developer of said command, but its not very user friendly, so how can or should you handle errors in CommandBox.
There are two ways to run commands via CommandBox: inside the CommandBox interactive shell, or one-at-a-time commands from your native shell.
If you open the interactive shell, you will see the CommandBox splash screen (ASCII art) and then you'll be presented with the CommandBox> prompt. You can enter as many commands as you wish in order and after each command is finished executing, you will be returned to the CommandBox prompt. If you have multiple commands you want to execute manually, this is the fastest method since CommandBox only loads once. This is also the only way to make use of features like tab complete and command history.
One of the features we really wanted to see in CommandBox is OS integration to be able to execute CFML as part of the OS like any other binary. Me personally, I wanted also to script in CFML instead of convoluted BASH or any type of shell scripting language. In CommandBox you have several ways of executing via the command line. Let's investigate a few.
Running CFML Files
You can very easily create ANY cfm file and put any code in it and execute it via CommandBox
CommandBox provides a lot of tooling and CLI functionality for CFML developers. But what if you wanted to run or test CFML code beyond the CommandBox REPL? This post explains a simple way that you can setup a genuine CFML SandBox with CommandBox.
In today's world, we use frameworks, and separate concerns with MVC or MV*, we strive for Clean Code to make Uncle Bob proud, or Bossman Bob at least. Just because the “Run” function is all you need in a CFC (which extends the BaseCommand) for CommandBox to index the Command, doesn’t mean you have to jam all your code into that one function. Lets look at some simple code cleanup.
As I always say, "All work and no fun makes you a dull programmer!" Well, with CommandBox, we're here to fight boredom and productivity with the fun "Snake" game. This is the class game of moving an-ever growing snake around the map in 4 directions while eating up the apples. For every app the snake devours, it grows by one character in length.