16 Jul 19:22
Re: [groovy-user] CliBuilder inserts arguments
From: Kallin Nagelberg <kallin.nagelberg@...>
Subject: Re: [groovy-user] CliBuilder inserts arguments
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-07-16 17:22:14 GMT
Subject: Re: [groovy-user] CliBuilder inserts arguments
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-07-16 17:22:14 GMT
That being said, is there a simple way to grab command line entries and put them into groovy lists/maps?
It's tricky because all the quotes are removed, and so they cannot be directly evaluated as groovy scripts.
It's tricky because all the quotes are removed, and so they cannot be directly evaluated as groovy scripts.
On Wed, Jul 16, 2008 at 1:06 PM, Kallin Nagelberg <kallin.nagelberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Actually nvm that is my shell that's doing that.On Wed, Jul 16, 2008 at 1:03 PM, Kallin Nagelberg <kallin.nagelberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:Ok thanks, I'll try that.
I'm also noticing that the parser is stripping double quotes from my arguments. Is there a way to prevent that? I'm trying to allow groovy lists,maps as arguments.On Wed, Jul 16, 2008 at 10:53 AM, Russel Winder <russel.winder-DsImGR7CbQu8rjiVs5Nzzw@public.gmane.org> wrote:On Tue, 2008-07-15 at 17:00 -0400, Kallin Nagelberg wrote:UNLIMITED_VALUES may not do what you think it does. Moreover the
> I am using a CliBuilder like:
>
> CliBuilder cli = new CliBuilder(usage: usage)
> cli.A(longOpt: 'mainargs', required: false, args: UNLIMITED_VALUES,
> 'arguments for the main method')
>
> UNLIMITED VALUES is a constant from the Option class.
semantics changed between Commons CLI 1.0 and 1.1, and may well change
again in 1.2 (back to 1.0.
Moreover the behaviour of the default PosixParser is broken, you
probably want to use the GnuParser which is significantly less broken.Oh yes
> i notice when i run this from the command line like:
> groovy myscript.groovy -A asdf asdf asdf asdf
>
> There is an extra entry in the list, always at the second position:
> when I do a 'println opts.As' I get:
> ["asdf", "--", "asdf", "asdf", "asdf"]
>
> Is this a known issue?
CliBuilder uses the PosixParser by default, and as far as I can tell it
is completely broken when it comes to doing anything associated with
actually parsing options. GnuParser may help out here:
def cli = new CliBuilder ( usage : usage , parser : new GnuParser ( ) )
A number of people are praising JOpt Simple but as far as I can tell it
does not yet do as much as Commons CLI is supposed to do. Why the
person chose to start again with JOpt Simple rather than fix Commons CLI
is a question I cannot answer but it would be interesting to know.
--
Russel.
====================================================
Dr Russel Winder Partner
Concertant LLP t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road, f: +44 8700 516 084
London SW11 1EN, UK. m: +44 7770 465 077
.
RSS Feed