私の質問は次のとおりです。スクリプトを groovy MyScript.groovy -o mtest -f filetest で渡すと、スクリプトは -o オプションを取得できます。しかし、オプションの場所を変更すると。groovy MyScript.groovy -f filetest -o mtest -o のオプションが取得できない
なぜ?私は何かが恋しいですか?
グルーヴィーなコードは次のとおりです。
def cli = new CliBuilder()
cli.with {
usage: 'Self'
h longOpt:'help', 'U should input a analyze script with -o dataFileName!'
o longOpt:'output', 'The file which should be analyzed.', args:1, required:true
f longOpt:'file', 'File'
}
def opt = cli.parse(args)
def action
if( args.length == 0) {
cli.usage()
return
}
if( opt.h ) {
cli.usage()
return
}
println(args);
println(opt);
println(opt.o);
groovy MyScript.groovy -f filetest -o mtest
印刷結果: [-f, filetest,-o,mtest] groovy.util.OptionAccessor@66b51404 false
groovy MyScript.groovy -o mtest -f filetest の出力結果: [-o,mtest,-f, filetest] groovy.util.OptionAccessor@66b51404 mtest