0
オプションのエラーを取得するために、GroovyのCliBuilderを使用して、私の質問は: 私はスクリプトを渡すとき: グルーヴィーMyScript.groovy -o MTEST -fファイルテスト スクリプトは、-oオプションを得ることができます。 しかし、私はオプションの場所を変更します。 groovy MyScript.groovy -fファイルテスト-o mtest -oオプションは最初の引数でない場合
のオプションを取得できないのはなぜですか? 何か不足していますか?
Groovyのコードは次のとおり
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、ファイルテスト、-o、MTEST] [email protected]偽
グルービーMyScript.groovy -o MTEST -fファイルテスト 印刷結果である: [-o、MTEST、-F、ファイルテスト] [email protected] MTEST
i'amが起こる何を混乱させる:私はいくつかのオプションを渡す場合は、 gammachen