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

Unknown options are ignored instead of throwing UnrecognizedOptionException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1
    • Component/s: CLI-1.x
    • Labels:
      None
    • Bugzilla Id:
      17662

      Description

      CLI does not handle unknown options, i.e. throw an 'UnrecognizedOptionException'.
      The reason is that the logic of PosixParser.processOptionToken() is incomplete:

      if (this.options.hasOption(token))

      { currentOption = this.options.getOption(token); tokens.add(token); }

      else if (stopAtNonOption)

      { eatTheRest = true; }

      ie. if the stopAtNonOption is not set and the token is unknown, it
      will be ignored. there has to be a default case added:

      else

      { tokens.add(token); }

      in which case the caller will throw the proper exception, because
      in Parse there is another check whether the option exists.

      i would've submitted a patch but did not find where to, sorry.
      peter

        Attachments

        1. cli-6.patch
          0.9 kB
          Oliver Heger
        2. ASF.LICENSE.NOT.GRANTED--patch
          0.4 kB
          Brian Hanson

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              peter.kunszt@cern.ch Peter Kunszt
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: