15 Jul 22:56
[groovy-user] CliBuilder inserts arguments
From: Kallin Nagelberg <kallin.nagelberg@...>
Subject: [groovy-user] CliBuilder inserts arguments
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-07-15 21:00:02 GMT
Subject: [groovy-user] CliBuilder inserts arguments
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-07-15 21:00:02 GMT
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.
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 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.
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?
.
Moreover the behaviour of the default PosixParser is broken, you
probably want to use the GnuParser which is significantly less broken.
> 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?
Oh yes
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.
RSS Feed