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:50:26 UTC

[groovy] branch master updated: GROOVY-9519: also fix groovy.cli.internal.CliBuilderInternal

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8377e40  GROOVY-9519: also fix groovy.cli.internal.CliBuilderInternal
8377e40 is described below

commit 8377e40fccfa82e251aa7b7f2ffbae40f95ff101
Author: Remko Popma <re...@yahoo.com>
AuthorDate: Wed Apr 29 15:50:14 2020 +0900

    GROOVY-9519: also fix groovy.cli.internal.CliBuilderInternal
---
 src/main/groovy/groovy/cli/internal/OptionAccessor.groovy | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/main/groovy/groovy/cli/internal/OptionAccessor.groovy b/src/main/groovy/groovy/cli/internal/OptionAccessor.groovy
index af6105a..5d89ecd 100644
--- a/src/main/groovy/groovy/cli/internal/OptionAccessor.groovy
+++ b/src/main/groovy/groovy/cli/internal/OptionAccessor.groovy
@@ -126,6 +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
+
+            // 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