在下面的代码中进行解析时,对于整数值,我看到错误。其余的String选项运行良好。有人可以指出int Options是否需要其他行为?
import org.kohsuke.args4j.*;
@Getter
@ToString
class foo {
@Option(name = "--a",
required = true)
private String a;
@Option(name = "--b",
required = true)
private String b;
@Option(name = "--c",
required = true)
private String c;
@Option(name = "--d",
required = true)
private int d;
public test(String[] args) throws RuntimeException {
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) {
String[] commandArgs = { "--a val1",
"--b val2",
"--c val3",
"--d 12" };
foo j = new foo(commandArgs);
}
}
错误:
Exception in thread "main" java.lang.RuntimeException: org.kohsuke.args4j.CmdLineException: Option "--d" takes an operand
我得到的错误仅适用于int选项。