我想要类似的东西:
java programName -jobs1 -C 10 -W 20
java programName -job2
java programName -job3
有内容:
Option o1 = new Option("job2", "some desc");
Option o2 = new Option("job3" , "(some desc")
Option o3 = OptionBuilder.hasArgs(2).withArgName( "W" ).withArgName("C").withDescription( "Some desc" ).create("job1")
Option o4 = new Option("help");
Options os = new Options().addOption(o1).addOption(o2).addOption(o3).addOption(o4).
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp( "ProgramName", options );
...输出是:
Usage ProgramName
-job1 <c> Some Desc
-job2 Some desc
-job3 Some desc
-help Print this message
我希望-job1
它应该打印-job1 -C <> -W <>
我错过了什么吗?它不适用于一个以上的论点。顺便说一句,我使用commons-cli 1.2
.