使用帮助消息中的 Picocli 选项列表对齐问题
Picocli option list alignment problem in usage-help message
我正在使用一个使用 PicoCLI v4.0.0-alpha-3 的命令。 No matter which options I try, the one that shows at the top (when the list of options is displayed in the CL) is always to the right of the other options.如何配置才能使命令的所有选项在同一级别对齐?
@CommandLine.Command(name = "",
description = "test",
header = "%n@|green test|@",
footer = {"",
"@|cyan Press Ctrl-D to exit the CLI.|@",
""},
version = "1.0.0",
showDefaultValues = true,
optionListHeading = "@|bold %nOptions|@:%n",
subcommands = {
Abc.class,
Def.class
})
public class Tester implements Callable<Integer> {
@Option(names = {"-v", "--verbose"}, description = "Verbose mode. Helpful for troubleshooting.")
private boolean verboseMode;
@Option(names = {"-a", "--autocomplete"}, description = "Generate sample autocomplete")
private boolean autocomplete;
在 CLI 上显示
Options:
--v, --version Show version info and exit.
-a, --autocomplete Generate sample autocomplete
第一个选项总是错位。我试图确保第一个选项与其他选项在同一级别对齐。
您可能发现了一个错误。我会调查的。
更新:
仔细观察输出:
Options:
--v, --version Show ...
-a, --autocomplete Generate ...
您可以看到 --v
选项和 --version
选项都有两个前导 -
连字符。这就是为什么 picocli 将两者都视为“多头期权”并将它们放在多头期权的列中。
如果您为 --v
选项提供单个前导连字符,使其成为 POSIX-compliant 短选项 -v
,您应该会看到它正确排列。
我正在使用一个使用 PicoCLI v4.0.0-alpha-3 的命令。 No matter which options I try, the one that shows at the top (when the list of options is displayed in the CL) is always to the right of the other options.如何配置才能使命令的所有选项在同一级别对齐?
@CommandLine.Command(name = "",
description = "test",
header = "%n@|green test|@",
footer = {"",
"@|cyan Press Ctrl-D to exit the CLI.|@",
""},
version = "1.0.0",
showDefaultValues = true,
optionListHeading = "@|bold %nOptions|@:%n",
subcommands = {
Abc.class,
Def.class
})
public class Tester implements Callable<Integer> {
@Option(names = {"-v", "--verbose"}, description = "Verbose mode. Helpful for troubleshooting.")
private boolean verboseMode;
@Option(names = {"-a", "--autocomplete"}, description = "Generate sample autocomplete")
private boolean autocomplete;
在 CLI 上显示
Options:
--v, --version Show version info and exit.
-a, --autocomplete Generate sample autocomplete
第一个选项总是错位。我试图确保第一个选项与其他选项在同一级别对齐。
您可能发现了一个错误。我会调查的。
更新:
仔细观察输出:
Options:
--v, --version Show ...
-a, --autocomplete Generate ...
您可以看到 --v
选项和 --version
选项都有两个前导 -
连字符。这就是为什么 picocli 将两者都视为“多头期权”并将它们放在多头期权的列中。
如果您为 --v
选项提供单个前导连字符,使其成为 POSIX-compliant 短选项 -v
,您应该会看到它正确排列。