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

Awkward behavior of Option.builder() for multiple optional args

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.6.0
    • 1.7.0
    • None
    • None

    Description

      This is to flag the breaking change for 1.6.0 as mentioned here:
      https://github.com/apache/commons-cli/commit/34278395b6115752774c3d16a00292591da2dde3#comments

      The possible fixes seem to be:

      • add Javadoc for the numberOfArgs and optionalArg methods saying that the former must come after the latter.
      • make optionalArg fail (early) if the number of args is already set, so this change in behavior becomes explicit via the API rather than just a behavioral breakage later.
      • tweak the behavior of optionalArg to only adjust the arg count if not already set. This removes the implicit assumption of size 1 which I think better aligns with what you get when using the (deprecated) OptionBuilder#hasOptionalArgs(int). I'll create a PR for this possible fix.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: