【发布时间】:2017-11-28 11:31:01
【问题描述】:
嘿,我正在使用Jcommander 库来解析命令行参数。 我的问题是 Jcommander 生成的使用消息的格式。 这是使用函数的输出:
Usage: mvnUploader [options]
Options:
* -d, --directory
the directory of the artifacts to upload
-h, --help
print help message
我希望选项和描述在同一行
我的 args 类:
public class OptionalArgs {
@Parameter(names = {"-d", "--directory"}, required = true, description =
"the directory of the artifacts to upload")
private String pathToArtifacts;
@Parameter(names ={"-h", "--help"} , help = true, description = "print help
message")
private boolean help = false;
public String getPathToArtifacts() {
return pathToArtifacts;
}
public boolean isHelp() {
return help;
}
}
【问题讨论】:
-
使用方法的格式是硬编码的。您可以使用
usage()的不同实现编写自己的JCommander子类。
标签: java jcommander