jcommander用法格式



嘿,我正在使用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;
 }
}

我恐怕@RealSkeATCIC是正确的。困扰您位于jcommander.java,第1210行中的线包装。

 out.append(indent).append("  "
    + (parameter.required() ? "* " : "  ")
    + pd.getNames()
    + "n");

IMHO自定义含义。usage()的努力很大,因为您必须从JCommander.java补偿约100行代码。引入可配置UsagePrinter类的拉请求呢?

最新更新