What's the best way to test and develop a custom command?

I’m starting to look into making custom CommandBox commands, and I was curious what the best technique is for working on this. I have a repository I’ve created where I’ll be working on my command, but I’m not sure the best way to keep that synced with the ~/.CommandBox/commands folder.

Is there a way to specify additional directories of commands? Or to temporarily link a folder as a command folder (like the npm link command)?

My other question is what is the best way to write tests for CommandBox commands?


Great questions Miles! This is new-ish territory so perhaps you can help us determine some best practices.

For the custom commands I’ve created, I’ve just edited the code directly in the commands folder, and then moved it to the actual Git repo if I wanted to commit it. That worked, but isn’t really elegant. Here’s some ideas:

  • Create a symlink in the commands folder. You would need to do this manually. Should work great if your command is in a sub folder (namespace) but wouldn’t work if your command was just a single CFC at the top level. This would be “fixed” if we ever do this ticket: COMMANDBOX-121
  • Add a custom command location. If you look in CommandService.cfc, you can see if simply loops over an array of command locations injected by wirebox as commandLocations@constants. You can add additional locations in /commandbox/system/config/WireBox.cfc. I’ve thought about having a config option to easily add additional command locations without editing the code, but I’ve never implemented it.
  • Another option, is to use the new “folder:” endpoint in CommandBox 2.0 beta to “install” the command from it’s location. You’d need to run something akin to

    install “C:/myCustomCommands/CoolCommand”
    every time you changed the code to re-install it in CommandBox.



ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I linked mine in too, kinda messy… one of the issues as it is now…
We need a NAMESPACE folder, in inside that, it looks deeper for the namespace


Commandbox would not register the repo, but the folder inside the repo for the actual command.
I say put it in namespaces, so you could not do that with custom adhoc commands you add.

Maybe call it namespace_repos or something, so you know its for repos, but yes, this is the toughest thing about making commands, and then submitting it, the workflow isn’t there.
Of course you could just assume all commands are a repo, then i could do this


Thats easiest, but goes against what you’re doing.
So do you break backwards compat?
Or add a convention to work around it, as I suggest above.

My 2 cents, i’ll let the smart people decide on the best idea.

Gavin Pickin

I think COMMANDBOX-121 would pretty much allow for that. It follows a sort of ColdBox module approach with a command convention inside of it. Honestly, I really wish I just had ColdBox modules available to me-- or I suppose having modules as a first class citizen of the CFML engine would be nice too :slight_smile: I’d like to have installable/uninstallable features of CommandBox (be it modules, tasks, listeners, etc) that could be installed in a standardized way into the CommandBox core. I really miss ColdBox’s creature comforts when I’m not working inside of it!



I think the “custom command location” technique is the route I’ll take a look at. The way I setup my repository is as a repository of all our custom commands, so it already has “namespace” folders in it for organization. It sounds like that will work well with how things work now in CommandBox.

Now to expand on part 2 of my original question: is there any way to write xUnit or BDD tests commands? Certainly, you’d have methods that perform logic that could easily be tested, but does anyone have any tips or tricks from actively testing their commands?