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

ArgumentBuilder.withDefault has no effect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.0
    • None
    • CLI-2.x, Options definition
    • None

    Description

      When ArgumentBuilder.withDefault is called, the default is correctly stored in the internal state. The default is correctly loaded in the WriteableCommandLineImpl.defaultValues. However, if the option is omitted from the arguments to the application, and CommandLine.getValue() is called passing the option's trigger string (without re-specifying the default), then

      • WriteableCommandLineImpl.addOption will not have been called, which means
      • nameToOption will be missing the option, which means
      • getOption will return null, which means
      • getValue will return null.

      The only workaround to this is to either re-specify the default as a parameter to getValue(), or pass the option object instead of the trigger string.

      Attachments

        Activity

          People

            Unassigned Unassigned
            reinderien Greg Toombs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: