Skip to content

How to Create a Run Mode

Tim Olson edited this page Jun 23, 2014 · 3 revisions

Main Overview

JCommander is a command-line parser which makes it easy to attach command-line parameters to Java fields by using annotations. The Main class automatically discovers any subclasses of org.ccp.RunMode, then instantiates them with the root Injector, then registers the run mode instances with JCommander. After JCommander has parsed the command-line, Main then invokes the run() method of the chosen RunMode.

Create a New Run Mode

  1. Subclass org.ccp.RunModeBase (or implement org.ccp.RunMode)
  2. Specify the command-line command name by putting this JCommander annotation above the class: @Parameters(commandNames="my-command”)
  3. Use the singular @Parameter tag on any fields in your subclass to capture command-line info (see the JCommander docs)
  4. Implement the run() method
Clone this wiki locally