我是 Groovy 的新手,我试图了解 CliBuilder 上 args 属性的含义。我不确定这是否意味着选项可以采用的最大参数数量。
我有类似的东西
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)
当我调用脚本时,我使用
groovy test.groovy -b toto -p 10 11
但我得到:
toto
10
我不应该为 -p 选项获得 10 11 吗?如果不是,args 是什么意思?
谢谢
最佳答案
关于scripting - 'args' 在 CliBuilder 上是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6832144/