4 messages in org.codehaus.groovy.userRe: [groovy-user] How much of CliBuil...
FromSent OnAttachments
Bogdan CalmacMar 17, 2008 5:55 pm 
Gerrit GeensMar 18, 2008 12:05 am 
Russel WinderMar 18, 2008 12:33 am 
Russel WinderMar 18, 2008 12:40 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [groovy-user] How much of CliBuilder does work?Actions...
From:Russel Winder (russ@concertant.com)
Date:Mar 18, 2008 12:40:27 am
List:org.codehaus.groovy.user

On Tue, 2008-03-18 at 08:05 +0100, Gerrit Geens wrote:

There are a number of issues with the Commons CLI 1.0/1.1 classes (that have nothing to do with Groovy itself!). A bunch of them are listed in the CliBuilderTest.groovy sources.

Hey, someone read all my comments :-)

One of these issues is that your first example won't work with the default Posix parser: * <p>There appear to be issues when using the <code>PosixParser</code> &ndash; when an option with a * parameter is passed using a long form and a single letter parameter of some sort has been declared (the * problem does not occur if no single letter option has been declared) then the value "--" is returned * instead of the option parameter value. This problem does not happen using the * <code>GnuParser</code>.</p>

Is there an argument for switching the Groovy default from PosixParser to GnuParser?

If you change the example to use the Gnu parser then it will work:

def cli = new CliBuilder(usage: 'groovy Hello -t', parser: new org.apache.commons.cli.GnuParser ()) cli.t(argName:'person', longOpt:'to', args:1, required:true, 'person to say hello to') opt = cli.parse(['--to', 'me']) println "t: $opt.t"

Will print:

t: me

I haven't tried this particular code but can confirm that Gant has all the same issues and using GnuParser worked where PosixParser does not.

With regards to your second problem: in the current version you should use the short name to get the value.

'Fraid so. long options work in CLI 1.1 but not in CLI 1.0.

Personally I've had so much issues with CLI 1.0/1.1 that I started developing a new Groovy builder for Commons CLI 2. Even though the CLI 2 library is not really released and development has stalled IMHO CLI 2 gives me less headaches ;-)

Can I propose we (and any other interested parties) club together and push this. Cli2Builder should solve many problems. There are 4 places in the Groovy code where a shift from CLI1.0 to CLI 2.0 would really help a lot. Gant really needs this, but I cannot change for Gant unless Groovy has changed since to ship CLI 1.0 and 2.0 jars seems ridiculous.

I can have another bout of pressuring Henri et al. to actually release Commons CLI 2.0. As you can see from https://issues.apache.org/jira/browse/CLI-143 there is unfinished business. -- Russel. ==================================================== Dr Russel Winder Partner

Concertant LLP t: +44 20 7193 9203 41 Buckmaster Road, f: +44 8700 516 084 London SW11 1EN, UK. m: +44 7770 465 077