You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Greg Toombs (JIRA)" <ji...@apache.org> on 2015/05/14 12:40:59 UTC

[jira] [Created] (CLI-250) ArgumentBuilder.withDefault has no effect

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)