groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8557) Verify that CliBuilder-based applications work correctly with picocli version of CliBuilder
Date Thu, 26 Apr 2018 21:30:00 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-8557?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16454898#comment-16454898
] 

Remko Popma commented on GROOVY-8557:
-------------------------------------

One incompatibility still exists: groovydoc.Main, shell.Main and Console.groovy all define
the {{classpath}} option twice:
{code}
def cli = new CliBuilder(usage : 'groovydoc [options] [packagenames] [sourcefiles]', writer:
io.out, posix:false)
...
cli.classpath(messages['cli.option.classpath.description'])         // <1>
cli.cp(longOpt: 'classpath', messages['cli.option.cp.description']) // <2>
...
{code}

I assume the above code was to support both a {{\-classpath <1>}} and a {{--classpath
<2>}} option. 

I am surprised by this, because the commons-cli DefaultParser already accepts long options
with both one and two preceding hyphens. (See {{CliBuilderTest.testMixedBurstingAndLongOptions}}.)


In fact, to simulate commons-cli's behaviour, {{groovy.cli.picocli.CliBuilder}} implicitly
registers all long options twice: once with one and once with two preceding hyphens.  Unfortunately,
because of this, with the picocli version of CliBuilder the above code gives the following
error:
{code}
picocli.CommandLine$DuplicateOptionAnnotationsException: Option name '-classpath' is used
by both option --classpath and option -classpath
{code}

So, some change is needed to migrate groovydoc.Main, shell.Main and Console.groovy to the
picocli version of CliBuilder.
Should we:
# modify groovydoc.Main, shell.Main and Console.groovy to only add the {{\-cp/--classpath
<2>}} option (and let CliBuilder take care of registering the long option with both
one and two hypens in the underlying parser), or 
# modify the picocli version of CliBuilder to ensure that long options are registered only
once in the underlying parser (perhaps with a flag to switch this on/off)? Then the application
can register {{classpath}} with both one and two hyphens, if this is desirable.

> Verify that CliBuilder-based applications work correctly with picocli version of CliBuilder
> -------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8557
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8557
>             Project: Groovy
>          Issue Type: Task
>          Components: command line processing
>            Reporter: Remko Popma
>            Priority: Major
>
> Follow-up task for GROOVY-8520. The following applications depend on CliBuilder:
> * groovy-console_main/groovy.ui.Console.groovy
> * groovy-docgenerator_main/org.codehaus.groovy.tools.DocGenerator.groovy
> * groovy-groovydoc_main/org.codehaus.groovy.tools.groovydoc.Main.groovy
> * groovy-groovysh_main/org.codehaus.groovy.tools.shell.Main.groovy (uses custom HelpFormatter)
> This task is to verify that the above applications work correctly with the picocli version
of CliBuilder.



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

Mime
View raw message