I'm a newbie on Groovy and I'm trying to understand what's the meaning of args attribute on CliBuilder. I'm not sure if it means the max number of parameters that an option can take.
I have something like
import java.text.*
def test(args) {
def cli = new CliBuilder(usage: 'test.groovy brand instance')
cli.with {
h longOpt: 'help', 'Show usage information'
}
cli.b(argName:'brand', args: 1, required: true, 'brand name')
cli.p(argName:'ports', args: 2, required: true, 'ports')
def options = cli.parse(args)
if (!options) {
return
}
if (options.h) {
cli.usage()
return
}
println options.b
println options.p
}
test(args)
When I call the script I use groovy test.groovy -b toto -p 10 11
But I get:
toto
10
Shouldn't I get 10 11 for the -p option? If not, what does args mean?
Thanks
This post here should explain how the args
parameter works
Basically, you need to add a plural s
to your println
line like so:
println options.bs
That should then print:
[10, 11]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With