Blog

Gavin Pickin

February 10, 2015

Spread the word


Share your thoughts

Using a command line tool, like CommandBox, you look for those feature comforts, that can make or break the UI. With CommandBox, one of the big wins, is HELP. Most command line tools allow you to type help and get some general help, but CommandBox goes a step further, you can get Help the Global Level, Namespace Help, and even help at the Command Level.

Global Help

To get an overall list of all the commands you have available to run, simply type help at the shell.

Global Help

 

Namespace Help

Next, drill down and get help on a specific namespace like server.

Namespace Help

 

Command Help

And finally, get help on a single command such as server stop. We can see the command is also aliased as just stop as well as all the possible parameters and their types along with a few sample ways to call the command.

Command Help

 

Thats great, all the built in commands have solid help, but being a community tool, what about when someone else makes a command, I’m sure they won’t have great help too.

That is where you are wrong… CommandBox uses JavaDoc comments to help generate the help for the CLI and even Tab Completion and Hints. There is no excuse for not including help in your Commands, because you can just annotate your functions and arguments/params and you have Help available for all your users.

Let's look at the stop.cfc inside CommandBox itself to see how this is generated.
A simple comment above the component is output.

  • Text outputs normally.
  • A period represents a blank line.
  • {code:bash} and {code} surround the code to make it stand out.

The comments above the run function define a hint, or description for the parameter. Tab completion is another great help when using the CLI, and CommandBox makes that easy by prompting boolean values with true/false, and parameters that include directory, destination, file or path in their names will get file system suggestions for tab complete. Of course can also give custom options, static options where you provide a list in the comment itself, or in this case, the options for Name are dynamically created from a optionsUDF called serverNameComplete that returns the list of running servers.

/**
 * Stop an embedded CFML server.  Run command from the web root of the server, or use the short name.
 * .
 * {code:bash}
 * server stop
 * server stop serverName
 * server stop serverName --forget
 * server stop --all
 * {code}
 **/
component extends="commandbox.system.BaseCommand" aliases="stop" excludeFromHelp=false {
      /**
      * @name.hint the short name of the server to stop
      * @name.optionsUDF serverNameComplete
      * @directory.hint web root for the server
      * @forget.hint if passed, this will also remove the directory information from disk
      * @all.hint If true, stop ALL running servers
      **/
     function run(
          string name="",
          string directory="",
          boolean forget=false,
          boolean all=false ){
          //Lots of code in here
     }

     function serverNameComplete() {
          return serverService.getServerNames();
     }

}

 

Help and Tab Completion is great for any CLI User, and even the commands you build can be as professional and helpful as anything else out there.
What command are you going to build?

 

More information on how to use the help when running the CLI
More information on how to build help into the commands you build.

Add Your Comment

Recent Entries

BoxLang 1.0.0 Beta 23 Launched

BoxLang 1.0.0 Beta 23 Launched

The latest release of BoxLang, Beta 23, marks a significant step forward in our journey to create the ultimate dynamic language for the JVM. Packed with powerful new features, important bug fixes, and thoughtful optimizations, this update is designed to make your development experience smoother, faster, and more reliable, especially after now starting to take 100s of comments and bug reports from our community.

Luis Majano
Luis Majano
November 23, 2024
TestBox Latest Updates and News!

TestBox Latest Updates and News!

We’re thrilled to have launched the new TestBox website and TestBox 6.0! If you haven’t had a chance to explore yet, visit TestBox to discover updated documentation, powerful resources, and features that make testing more efficient than ever.

Maria Jose Herrera
Maria Jose Herrera
November 21, 2024
Is Your ColdFusion Application Ready for the Future?

Is Your ColdFusion Application Ready for the Future?

In a rapidly evolving digital world, maintaining performance, security, and scalability for ColdFusion applications is more challenging than ever. Whether you're using Lucee or Adobe ColdFusion, legacy systems can become a bottleneck for growth, innovation, and user satisfaction. The need to future-proof your ColdFusion applications has never been more critical.

But where do you start?


The Hidden Costs of an Outdated ColdFusion Application

As you...

Cristobal Escobar
Cristobal Escobar
November 21, 2024