On 02/05/2016 11:27 PM, Russel Winder wrote:
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.

Yes, I realized that later. I posed basically the same question to the commons user list, but I didn't get any reply.

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


Reply via email to