[jira] [Resolved] (GROOVY-8740) groovy.util.CliBuilder doesn't handle parse errors correctly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (GROOVY-8740) groovy.util.CliBuilder doesn't handle parse errors correctly

JIRA jira@apache.org

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

Paul King resolved GROOVY-8740.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 2.5.2
                   3.0.0-alpha-4

Thanks for reporting the issue. I have changed the util CliBuilder to follow the same behavior as before.

If you ever switch to the picocli version of CliBuilder you will notice a difference in behavior. It has a few more options for handling unknown option-like parameters. We can possibly add an asBoolean method to the picocli OptionAccessor. Then if you use groovy truth to check that things went well you should get the closest possible equivalent to the current behavior.

> groovy.util.CliBuilder doesn't handle parse errors correctly
> ------------------------------------------------------------
>
>                 Key: GROOVY-8740
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8740
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 2.5.1
>            Reporter: Роман Донченко
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 3.0.0-alpha-4, 2.5.2
>
>
> In Groovy 2.5, {{groovy.util.CliBuilder}} is a wrapper that delegates to {{groovy.cli.commons.CliBuilder}}. However, this wrapper doesn't correctly handle the case when the arguments fail to be parsed.
> Here's how it works with the real {{CliBuilder}}:
> {code:java}
> groovy:000> options = new groovy.cli.commons.CliBuilder(stopAtNonOption: false).parse(['-x'])
> error: Unrecognized option: -x
> usage: groovy
> ===> null{code}
> And here's what happens with the wrapper:
> {code:java}
> groovy:000> options = new groovy.util.CliBuilder(stopAtNonOption: false).parse(['-x'])
> error: Unrecognized option: -x
> usage: groovy
> ===> groovy.util.OptionAccessor@6fc3e1a4
> groovy:000> options.arguments()
> ERROR java.lang.NullPointerException:
> Cannot invoke method arguments() on null object{code}
> I get an object that pretends to be {{null}}, but isn't. So I can't determine whether the parsing was successful or not.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)