groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russel Winder <rus...@winder.org.uk>
Subject Re: Example of CliBuilder with "optionalArg: true"?
Date Sat, 06 Feb 2016 07:27:27 GMT
On Tue, 2016-02-02 at 19:56 +0000, KARR, DAVID wrote:
> > 
[…]
> With a  simple script like this:
> ----------------
> def cli = new CliBuilder()
> cli.with { 
>   f(args: 1, optionalArg: true, "set a value")
> }
> def options = cli.parse(args)
> def fval = options.f
> println "fval[" + fval + "] class[" + fval.getClass().getName() + "]"
> def fvalue = options.fs
> println "fvalue[" + fvalue + "]"
> ---
> 
> If I run this with "-f abc", I get:
> --------------
> fval[abc] class[java.lang.String]
> fvalue[[abc]]
> ----------------
> 
> But if I run it with "-f", I get:
> ------------
> fval[true] class[java.lang.Boolean]
> fvalue[true]
> -------------
> 
> I suppose I could hack something with this information, but I would
> think there would be something more explicit to tell me whether an
> argument was supplied for the option.

CliBuilder is a very thin wrapper around commons.cli, it is basically
just an adapter with little or no functionality of its own. I posit
therefore that what you are seeing is just the behaviour stemming from
commons.cli, or if not then it is a bug.

I'll see if I can have a play with this this weekend.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


Mime
View raw message