Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-20

MissingArgumentException: no argument for <option> is thrown when the option's parameter equals to an existing option.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 2.0
    • CLI-2.x
    • None
    • Operating System: All
      Platform: PC

    • 15046

    Description

      MissingArgumentException: no argument for <option> is thrown when the option's
      parameter equals to an existing option. Example:
      -l option1
      -m option2

      //this will throw exception
      $app -l m

      Test case follows:
      import junit.framework.*;
      import org.apache.log4j.*;
      import org.apache.commons.cli.*;

      public class CliTest extends TestCase {
      CommandLineParser parser;

      public CliTest(String name)

      { super(name); }

      protected void setUp() throws Exception

      { parser = new PosixParser(); }

      public void testParamNamedAsOption() throws Exception {
      final String[] CLI_ARGS = new String[]

      {"-z", "c"}

      ;
      Option option = new Option("z", "timezone", true,
      "affected option");
      Options cliOptions = new Options();
      cliOptions.addOption(option);
      parser.parse(cliOptions, CLI_ARGS);

      //now add conflicting option
      cliOptions.addOption("c", "conflict", true, "conflict option");
      parser.parse(cliOptions, CLI_ARGS);
      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            ledestin@amur.ru Dmitry Macsema
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: