[
https://issues.apache.org/jira/browse/GROOVY-9886?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-9886:
------------------------------
Component/s: command line processing
> Groovy 3: cli builder not honoring type correctly
> -------------------------------------------------
>
> Key: GROOVY-9886
> URL:
https://issues.apache.org/jira/browse/GROOVY-9886> Project: Groovy
> Issue Type: Bug
> Components: command line processing
> Reporter: Howard
> Priority: Major
>
> The following code runs in groovy 2 but not groovy 3
> {code}
> def cli = new CliBuilder(writer : new PrintWriter(System.out))
> def opt = 'a'
> def key = 'abc'
> def type = double.class
> def desc = 'abc'
> cli."$opt"(args: 1, longOpt: key, type: type, desc)
> def options = cli.parse(['--abc', '0.00'])
> options.getOptions().each {
> assert(it.getType().toString() == 'double')
> }
> {code}
> groovy 3 output
> {code}
> Assertion failed:
> assert(it.getType().toString() == 'double')
> | | | |
> | | | false
> | | 'class java.lang.String'
> | class java.lang.String
> [ option: a abc [ARG] :: abc :: class java.lang.String ]
> at ConsoleScript26$_run_closure1.doCall(ConsoleScript26:9)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at ConsoleScript26.run(ConsoleScript26:8)
> at jdk.internal.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)