【发布时间】:2021-05-06 07:55:35
【问题描述】:
我已将命令的 sortOptions 设置为 false,但我仍然在“用法”部分看到命令的选项按排序顺序排列。 我想看看他们的申报顺序。
示例代码
@Command(name = "application", subcommands = { AddSubCommand.class })
public class Sample implements Runnable {
@Spec CommandSpec spec;
@Override
public void run() {
throw new ParameterException(spec.commandLine(), "Specify a subcommand");
}
public static void main(String... args) {
new CommandLine(new Sample()).execute("add", "-h");
}
}
@Command(name = "add", sortOptions = false)
class AddSubCommand implements Runnable {
@Option(names = { "-h" }, usageHelp = true, hidden = true)
boolean helpFlag;
@Option(names = { "-i" }, required = true, description = "id")
int id;
@Option(names = { "-t" }, required = true, description = "type")
String type;
@Option(names = { "-c" }, required = true, description = "config")
String config;
public void run() {
// logic
}
}
输出
Usage: application add -c=<config> -i=<id> -t=<type>
-i=<id> id
-t=<type> type
-c=<config> configuration
期待
Usage: application add -i=<id> -c=<config> -t=<type>
-i=<id> id
-t=<type> type
-c=<config> configuration
【问题讨论】:
标签: picocli