title: Creating subcommands with commons-cli
body: <p>I'm trying to create a simple argument parser using commons-cli and I can't seem to figure out how to create the following options:</p>
  
  <pre><code>java ... com.my.path.to.MyClass producer 
  java ... com.my.path.to.MyClass consumer -j 8
  </code></pre>
  
  <p>The first argument to my program should be either <code>producer</code> or <code>consumer</code>, defining the mode which my program will run in. If it's in <code>consumer</code> mode, I'd like to have a <code>-j</code> argument which defines how many threads to service with.</p>
  
  <p>Here's what I've got so far:</p>
  
  <pre><code>Options options = new Options();
  options.addOption("mode", false, "Things.");
  
  HelpFormatter formatter = new HelpFormatter();
  formatter.printHelp("startup.sh", options);
  </code></pre>
  
  <p>When I print out these options, the <code>mode</code> parameter shows up as <code>-mode</code>. </p>
  
  <p>In Python's <code>argparse</code>, I'd just do the following:</p>
  
  <pre><code>parser = argparse.ArgumentParser()
  parser.add_argument('mode', choices=('producer', 'consumer'), required=True)
  parser.print_help()
  </code></pre>
  
  <p>This does exactly what I'm looking for. How can I do this in commons-cli?</p>