更多的是一个美学问题,但为什么打印 cli.usage() 最后给出一个空值?
def cli = new CliBuilder(usage:'helloWord')
cli.help('prints this message')
cli.project(args:1, argName:'project', 'project name')
cli.desc(args:2, argName:'desc', 'project description')
cli.f('force creation')
def options = cli.parse(args)
if (options.help){
print cli.usage()
return
}
使用 groovy helloWorld.groovy -help 输出
usage: helloWorld
-desc <desc> project description
-f force creation
-help prints this message
-project <project> project name
null