我正在使用 Pico CLI v4.0.0-alpha-3 和 jline v3。我有以下课程(使用注释)。当我运行主类时,我似乎无法运行命令并调用可调用对象。如果我只是传入参数,我可以调用可调用对象。
@CommandLine.Command(name = "Test CLI",
description = "CLI tool",
header = "%n@|green test cli |@",
footer = {"",
"@|cyan Press Ctrl-D to exit the CLI.|@",
""},
version = "1.0.0",
showDefaultValues = true,
optionListHeading = "@|bold %nOptions|@:%n",
subcommands = {
Sync.class,
Status.class
})
public class Tester implements Callable<Integer> {
private static final String PROMPT = "Test CLI> ";
private LineReaderImpl lineReader;
private PrintWriter out;
@Option(names = {"-u", "--username"}, required = true, description = "user name")
private String userName;
@Option(names = {"-p", "--password"}, required = true, description = "password")
private String password;
final Tester tester = new Tester();
final CommandLine cmd = prepareCommand(tester);
final int exitCode = cmd.execute(args);
当我运行 java 应用程序并使用参数运行命令时,不会调用可调用对象。当我简单地传入参数时,可调用对象被调用。关于如何解决此问题的任何想法,以便 CLI 用户必须传入命令和参数。