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:44 UTC

[groovy] branch GROOVY_3_0_X updated (04a2612 -> 2173396)

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

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


    from 04a2612  GROOVY-9528: improve "Property: parser" subsection title
     new 4efc6b1  GROOVY-9519: add failing test
     new 12884c3  GROOVY-9519: update failing test
     new 3982255  GROOVY-9519: zero default for non-Boolean type options should not be converted to false
     new 70308ec  GROOVY-9519: bugfix: savedTypeOptions use longest option name as key
     new 2173396  GROOVY-9519: also fix groovy.cli.internal.CliBuilderInternal

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/groovy/groovy/cli/internal/OptionAccessor.groovy     |  7 +++++++
 .../src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy  |  7 +++++++
 .../src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy  | 11 +++++++++++
 3 files changed, 25 insertions(+)


[groovy] 05/05: GROOVY-9519: also fix groovy.cli.internal.CliBuilderInternal

Posted by rp...@apache.org.
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 2173396a4b7e0ea0d4836a9bd29ab8edded81c71
Author: Remko Popma <re...@yahoo.com>
AuthorDate: Wed Apr 29 15:50:14 2020 +0900

    GROOVY-9519: also fix groovy.cli.internal.CliBuilderInternal
    
    (cherry picked from commit 8377e40fccfa82e251aa7b7f2ffbae40f95ff101)
---
 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


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

Posted by rp...@apache.org.
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


[groovy] 04/05: GROOVY-9519: bugfix: savedTypeOptions use longest option name as key

Posted by rp...@apache.org.
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 <re...@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


[groovy] 02/05: GROOVY-9519: update failing test

Posted by rp...@apache.org.
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 12884c38fd26059866226fc4e3320643fec8d6e0
Author: Remko Popma <re...@yahoo.com>
AuthorDate: Wed Apr 29 14:47:08 2020 +0900

    GROOVY-9519: update failing test
    
    (cherry picked from commit fdb0b086c8da10f41c0d5d09022cf36ee86bab13)
---
 .../src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy            | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/groovy-cli-picocli/src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy b/subprojects/groovy-cli-picocli/src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy
index 3be2110..2d24337 100644
--- a/subprojects/groovy-cli-picocli/src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy
+++ b/subprojects/groovy-cli-picocli/src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy
@@ -1081,7 +1081,7 @@ Usage: groovy [-hiV] [-cp] [-pa] [-pr] [--configscript=PARAM]
     }
 
     // GROOVY-9519
-    testIntOptionWithDefaultZeroShouldNotConvertToBooleanFalse() {
+    void testIntOptionWithDefaultZeroShouldNotConvertToBooleanFalse() {
         def cli = new CliBuilder()
         cli.i(type: Integer, longOpt: 'intTest', required: false, args: 1, defaultValue: '0', 'Testing integer with default value 0')
 


[groovy] 01/05: GROOVY-9519: add failing test

Posted by rp...@apache.org.
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 4efc6b1fa84ff336ee7ed9d857840f646fb6d26a
Author: Remko Popma <re...@yahoo.com>
AuthorDate: Wed Apr 29 14:11:33 2020 +0900

    GROOVY-9519: add failing test
    
    (cherry picked from commit cf60cee2a095f40c594fe3b295660a67a1729bdb)
---
 .../src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy  | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/subprojects/groovy-cli-picocli/src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy b/subprojects/groovy-cli-picocli/src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy
index c0de44a..3be2110 100644
--- a/subprojects/groovy-cli-picocli/src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy
+++ b/subprojects/groovy-cli-picocli/src/test/groovy/groovy/cli/picocli/CliBuilderTest.groovy
@@ -1080,4 +1080,15 @@ Usage: groovy [-hiV] [-cp] [-pa] [-pr] [--configscript=PARAM]
         assertNull(optionAccessor)
     }
 
+    // GROOVY-9519
+    testIntOptionWithDefaultZeroShouldNotConvertToBooleanFalse() {
+        def cli = new CliBuilder()
+        cli.i(type: Integer, longOpt: 'intTest', required: false, args: 1, defaultValue: '0', 'Testing integer with default value 0')
+
+        def opts = cli.parse([]) // no args, so defaults are applied
+        assert opts
+
+        assert Integer == opts.i.getClass()
+        assert opts.i == 0
+    }
 }