[jira] [Updated] (GROOVY-9599) CliBuilder: Option with "type: String, defaultValue ''" (empty String) results in NullObject if default value is applied

2020-06-21 Thread Remko Popma (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Remko Popma updated GROOVY-9599:

Affects Version/s: 2.5.11

> CliBuilder: Option with "type: String, defaultValue ''" (empty String) 
> results in NullObject if default value is applied
> 
>
> Key: GROOVY-9599
> URL: https://issues.apache.org/jira/browse/GROOVY-9599
> Project: Groovy
>  Issue Type: Bug
>  Components: command line processing
>Affects Versions: 2.5.11, 3.0.4
>Reporter: Remko Popma
>Assignee: Remko Popma
>Priority: Major
> Fix For: 3.0.5
>
>
> This is a follow-up ticket for GROOVY-9519:
> After checking with Groovy 3.0.4, it seems that only the "Integer with 
> defaultValue '0'" case was fixed, but not "String with defaultValue ''". The 
> latter became even worse. It still ignores the defaultValue, but instead of 
> creating a Boolean, it now creates a NullObject. Try this code:
> {code:java}
> @Grab('info.picocli:picocli-groovy:4.3.2')
> @GrabConfig(systemClassLoader=true)
> import groovy.cli.picocli.CliBuilder
> def cli = new CliBuilder(name: 'cliTest.groovy', stopAtNonOption: false)
> cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show 
> usage information')
> cli.a(type: String, longOpt: 'optA', required: false, args: 1, defaultValue: 
> '', 'Option a (optional)')
> def opts = cli.parse(args)
> opts || System.exit(1)
> if(opts.h) {
>   cli.usage()
>   System.exit(0)
> }
> println(opts.a.getClass())
> if (opts.a) {
>   println(opts.a)
> }
> {code}
> with Groovy 3.0.2:
> {code:java}
> % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy
> class java.lang.Boolean
> {code}
> and with Groovy 3.0.4:
> {code:java}
> % ~/tmp/groovy-3.0.4/bin/groovy ./cliTest.groovy
> class org.codehaus.groovy.runtime.NullObject
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (GROOVY-9599) CliBuilder: Option with "type: String, defaultValue ''" (empty String) results in NullObject if default value is applied

2020-06-21 Thread Remko Popma (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Remko Popma updated GROOVY-9599:

Fix Version/s: 2.5.13

> CliBuilder: Option with "type: String, defaultValue ''" (empty String) 
> results in NullObject if default value is applied
> 
>
> Key: GROOVY-9599
> URL: https://issues.apache.org/jira/browse/GROOVY-9599
> Project: Groovy
>  Issue Type: Bug
>  Components: command line processing
>Affects Versions: 2.5.11, 3.0.4
>Reporter: Remko Popma
>Assignee: Remko Popma
>Priority: Major
> Fix For: 3.0.5, 2.5.13
>
>
> This is a follow-up ticket for GROOVY-9519:
> After checking with Groovy 3.0.4, it seems that only the "Integer with 
> defaultValue '0'" case was fixed, but not "String with defaultValue ''". The 
> latter became even worse. It still ignores the defaultValue, but instead of 
> creating a Boolean, it now creates a NullObject. Try this code:
> {code:java}
> @Grab('info.picocli:picocli-groovy:4.3.2')
> @GrabConfig(systemClassLoader=true)
> import groovy.cli.picocli.CliBuilder
> def cli = new CliBuilder(name: 'cliTest.groovy', stopAtNonOption: false)
> cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show 
> usage information')
> cli.a(type: String, longOpt: 'optA', required: false, args: 1, defaultValue: 
> '', 'Option a (optional)')
> def opts = cli.parse(args)
> opts || System.exit(1)
> if(opts.h) {
>   cli.usage()
>   System.exit(0)
> }
> println(opts.a.getClass())
> if (opts.a) {
>   println(opts.a)
> }
> {code}
> with Groovy 3.0.2:
> {code:java}
> % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy
> class java.lang.Boolean
> {code}
> and with Groovy 3.0.4:
> {code:java}
> % ~/tmp/groovy-3.0.4/bin/groovy ./cliTest.groovy
> class org.codehaus.groovy.runtime.NullObject
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (GROOVY-9599) CliBuilder: Option with "type: String, defaultValue ''" (empty String) results in NullObject if default value is applied

2020-06-19 Thread Remko Popma (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Remko Popma updated GROOVY-9599:

Summary: CliBuilder: Option with "type: String, defaultValue ''" (empty 
String) results in NullObject if default value is applied  (was: CliBuilder: 
Option with "type: String, defaultValue 'x'" results in NullObject if default 
value is applied)

> CliBuilder: Option with "type: String, defaultValue ''" (empty String) 
> results in NullObject if default value is applied
> 
>
> Key: GROOVY-9599
> URL: https://issues.apache.org/jira/browse/GROOVY-9599
> Project: Groovy
>  Issue Type: Bug
>  Components: command line processing
>Affects Versions: 3.0.4
>Reporter: Remko Popma
>Assignee: Remko Popma
>Priority: Major
> Fix For: 3.0.5
>
>
> This is a follow-up ticket for GROOVY-9519:
> After checking with Groovy 3.0.4, it seems that only the "Integer with 
> defaultValue '0'" case was fixed, but not "String with defaultValue ''". The 
> latter became even worse. It still ignores the defaultValue, but instead of 
> creating a Boolean, it now creates a NullObject. Try this code:
> {code:java}
> @Grab('info.picocli:picocli-groovy:4.3.2')
> @GrabConfig(systemClassLoader=true)
> import groovy.cli.picocli.CliBuilder
> def cli = new CliBuilder(name: 'cliTest.groovy', stopAtNonOption: false)
> cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show 
> usage information')
> cli.a(type: String, longOpt: 'optA', required: false, args: 1, defaultValue: 
> '', 'Option a (optional)')
> def opts = cli.parse(args)
> opts || System.exit(1)
> if(opts.h) {
>   cli.usage()
>   System.exit(0)
> }
> println(opts.a.getClass())
> if (opts.a) {
>   println(opts.a)
> }
> {code}
> with Groovy 3.0.2:
> {code:java}
> % ~/tmp/groovy-3.0.2/bin/groovy ./cliTest.groovy
> class java.lang.Boolean
> {code}
> and with Groovy 3.0.4:
> {code:java}
> % ~/tmp/groovy-3.0.4/bin/groovy ./cliTest.groovy
> class org.codehaus.groovy.runtime.NullObject
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)