You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by rp...@apache.org on 2020/04/29 06:53:47 UTC

[groovy] 03/05: GROOVY-9519: zero default for non-Boolean type options should not be converted to false

This is an automated email from the ASF dual-hosted git repository.

rpopma pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 39822551fcceee7a016485620f48845502dbc579
Author: Remko Popma <re...@yahoo.com>
AuthorDate: Wed Apr 29 15:05:52 2020 +0900

    GROOVY-9519: zero default for non-Boolean type options should not be converted to false
    
    (cherry picked from commit 719cffb57458fa144081c67f5b295d16bdbe86ad)
---
 .../src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy            | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/subprojects/groovy-cli-picocli/src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy b/subprojects/groovy-cli-picocli/src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy
index 2ce0bb8..4fac7c1 100644
--- a/subprojects/groovy-cli-picocli/src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy
+++ b/subprojects/groovy-cli-picocli/src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy
@@ -126,6 +126,8 @@ class OptionAccessor {
         if (parseResult.commandSpec().findOption(name)) { // requested option was not matched: return its default
             def option = parseResult.commandSpec().findOption(name)
             def result = option.value
+            Class userSpecifiedType = savedTypeOptions[name]?.type // GROOVY-9519: zero default for non-Boolean type options should not be converted to false
+            if (userSpecifiedType && Boolean != userSpecifiedType) { return result }
             return result ? result : false
         }
         if (name.size() > 1 && name.endsWith('s')) { // user wants multi-value result