title: Apache command line parser bug?
body: <p>I got the code below from a sample code from tutorials point and tweaked it a little bit. </p>
  
  <p><strong>App.java</strong></p>
  
  <pre><code>public static void main(String[] args) throws ParseException {
          CommandTest t = new CommandTest();
          t.start(args);
  }
  </code></pre>
  
  <p><strong>CommandTest.java</strong></p>
  
  <pre><code>public class CommandTest {
  
      void start(String[] args) throws ParseException {
  
            //***Definition Stage***
            // create Options object
            Options options = new Options();
  
            // add option "-a"
            options.addOption(
                      Option.builder("a")
                          .longOpt("add")
                          .desc("add numbers")
                          .hasArg(false)
                          .valueSeparator('=')
                          .required(false)
                          .build()
                    );
  
            // add option "-m"
            options.addOption("m", false, "");
            options.addOption(
                      Option.builder("m")
                          .longOpt("multiply")
                          .desc("multiply numbers")
                          .hasArg(false)
                          .valueSeparator('=')
                          .required(false)
                          .build()
                    );
  
            //***Parsing Stage***
            //Create a parser
            CommandLineParser parser = new DefaultParser();
  
            //parse the options passed as command line arguments
            CommandLine cmd = parser.parse( options, args);
  
            //***Interrogation Stage***
            //hasOptions checks if option is present or not
            if(cmd.hasOption("a")) { 
               System.out.println("Sum of the numbers: " + getSum(args));
            } else if(cmd.hasOption("m")) {
               System.out.println("Multiplication of the numbers: " + getMultiplication(args));
            }
         }
  
         public static int getSum(String[] args) {
            int sum = 0;
            for(int i = 1; i &lt; args.length ; i++) {
               sum += Integer.parseInt(args[i]);
            } 
            return sum;
         }
  
         public static int getMultiplication(String[] args) {
            int multiplication = 1;
            for(int i = 1; i &lt; args.length ; i++) {
               multiplication *= Integer.parseInt(args[i]);
            } 
            return multiplication;
         }
  }
  </code></pre>
  
  <p>Now, my question is that, when i try to execute the above code with a parameter of <code>-multi</code> it will still be accepted? I've already set the options to receive only either <code>-m</code> or <code>-multiply</code>. However, it will still accept <code>-multi</code> </p>
  
  <p>I am using commons-cli-1.3.1 (im trying to debug a legacy code by the way)</p>
  
  <p>Note: Above source is a SAMPLE source only, no need to apply actual coding guidelines (good or bad) i just want to know why the behavior happens as it is.</p>