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 70308ec73514b998a9ef78403b02ad93fc077fe1
Author: Remko Popma <rem...@yahoo.com>
AuthorDate: Wed Apr 29 15:38:37 2020 +0900

    GROOVY-9519: bugfix: savedTypeOptions use longest option name as key
    
    (cherry picked from commit af8b21e475043673548f39dfaa5a1b30fd744d01)
---
 .../src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy       | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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 4fac7c1..4f9f2a4 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,8 +126,13 @@ 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
+
+            // GROOVY-9519: zero default for non-Boolean type options should 
not be converted to false
+            def longOpt = option.longestName()
+            longOpt = longOpt?.startsWith("--") ? longOpt.substring(2) : 
longOpt
+            Class userSpecifiedType = savedTypeOptions[longOpt]?.type
             if (userSpecifiedType && Boolean != userSpecifiedType) { return 
result }
+
             return result ? result : false
         }
         if (name.size() > 1 && name.endsWith('s')) { // user wants multi-value 
result

Reply via email to