Search in sources :

Example 1 with Main

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;
}
Also used : CommandLine(picocli.CommandLine) CommandSpec(picocli.CommandLine.Model.CommandSpec) Main(org.keycloak.quarkus.runtime.cli.command.Main) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 Main (org.keycloak.quarkus.runtime.cli.command.Main)1 CommandLine (picocli.CommandLine)1 CommandSpec (picocli.CommandLine.Model.CommandSpec)1