use of org.keycloak.quarkus.runtime.cli.command.Main in project keycloak by keycloak.
the class Picocli method createCommandLine.
public static CommandLine createCommandLine(List<String> cliArgs) {
CommandSpec spec = CommandSpec.forAnnotatedObject(new Main(), new DefaultFactory()).name(Environment.getCommand());
for (CommandLine subCommand : spec.subcommands().values()) {
CommandSpec subCommandSpec = subCommand.getCommandSpec();
// help option added to any subcommand
subCommandSpec.addOption(OptionSpec.builder(Help.OPTION_NAMES).usageHelp(true).description("This help message.").build());
}
addOption(spec, Start.NAME, hasAutoBuildOption(cliArgs), true);
addOption(spec, StartDev.NAME, true, true);
addOption(spec, Build.NAME, true, hasAutoBuildOption(cliArgs));
CommandLine cmd = new CommandLine(spec);
cmd.setExecutionExceptionHandler(new ExecutionExceptionHandler());
cmd.setParameterExceptionHandler(new ShortErrorMessageHandler());
cmd.setHelpFactory(new HelpFactory());
cmd.getHelpSectionMap().put(SECTION_KEY_COMMAND_LIST, new SubCommandListRenderer());
cmd.setErr(new PrintWriter(System.err, true));
return cmd;
}
Aggregations