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

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 2.0
    • Component/s: CLI-2.x
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: PC

    • Bugzilla Id:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: