title: Define an option that has both a mandatory and optional argument
body: <p>I am currently trying to come up with a way to build a command-line option that when provided can either take one required argument or a second optional argument (in addition to the required one). I am trying to achieve this using apache commons cli.</p>
  
  <p>i.e. myProgram -a  [integer]</p>
  
  <pre><code>myProgram -a "test" --&gt; isValid
  myProgram -a "test" 2 --&gt; also isValid
  </code></pre>
  
  <p>I have tried:
  <code>Option.builder("a").hasArg().numberOfArgs(2).optionalArg(true).build();</code></p>
  
  <p>&amp;</p>
  
  <p><code>Option.builder("a").hasArg().numberOfArgs(2).build();</code></p>
  
  <p>Neither of which is working as desired. The first example makes both arguments optional and it allows for passing empty arguments which is against the requirements.</p>
  
  <p>The second example makes both parameters required and fails when only the string type arg is provided.</p>
  
  <p>I have looked at the documentation for commons cli but the usage cases they provided didnt touch complex cases like this one, and similarly did not get much details from the api docs.</p>
  
  <p>I expect the program to fail when -a is provided with no value, but to succeed when provided with 1 or 2 arguments as shown previously.</p>