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

MissingArgumentException when DefaultParser processes an option value which starts with hyphen/dash.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.4
    • None
    • Parser
    • None

    Description

       

      When processing option value which starts with hyphen/dash like -sec-attr -password1 , exception [1] occurs. If the current token start with dash, it will be processed as an option and therefore this will not be set as a value to the previous option, which will cause [1]. The only way to set such value is to use equals sign like -sec-attr=-password1. In this case the whole token is processed as option=value pair and the correct value will be set.

       

      [1] 

      org.apache.commons.cli.MissingArgumentException: Missing argument for option: xorg.apache.commons.cli.MissingArgumentException: Missing argument for option: x at org.apache.commons.cli.DefaultParser.checkRequiredArgs(DefaultParser.java:259) at org.apache.commons.cli.DefaultParser.handleOption(DefaultParser.java:669) at org.apache.commons.cli.DefaultParser.handleConcatenatedOptions(DefaultParser.java:773) at org.apache.commons.cli.DefaultParser.handleShortAndLongOption(DefaultParser.java:590) at org.apache.commons.cli.DefaultParser.handleToken(DefaultParser.java:291) at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:168) at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:129)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ivassile ilia
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: