Greg Toombs created CLI-250:
-------------------------------

             Summary: ArgumentBuilder.withDefault has no effect
                 Key: CLI-250
                 URL: https://issues.apache.org/jira/browse/CLI-250
             Project: Commons CLI
          Issue Type: Bug
          Components: CLI-2.x, Options definition
    Affects Versions: 2.0
            Reporter: Greg Toombs


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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to