Search in sources :

Example 66 with CommandLine

use of picocli.CommandLine in project keycloak by keycloak.

the class ShortErrorMessageHandler method handleParseException.

public int handleParseException(ParameterException ex, String[] args) {
    CommandLine cmd = ex.getCommandLine();
    PrintWriter writer = cmd.getErr();
    writer.println(cmd.getColorScheme().errorText(ex.getMessage()));
    UnmatchedArgumentException.printSuggestions(ex, writer);
    CommandSpec spec = cmd.getCommandSpec();
    writer.printf("Try '%s --help' for more information on the available options.%n", spec.qualifiedName());
    return cmd.getExitCodeExceptionMapper() != null ? cmd.getExitCodeExceptionMapper().getExitCode(ex) : spec.exitCodeOnInvalidInput();
}
Also used : CommandLine(picocli.CommandLine) CommandSpec(picocli.CommandLine.Model.CommandSpec) PrintWriter(java.io.PrintWriter)

Example 67 with CommandLine

use of picocli.CommandLine in project keycloak by keycloak.

the class AbstractStartCommand method run.

@Override
public void run() {
    doBeforeRun();
    CommandLine cmd = spec.commandLine();
    KeycloakMain.start((ExecutionExceptionHandler) cmd.getExecutionExceptionHandler(), cmd.getErr());
}
Also used : CommandLine(picocli.CommandLine)

Example 68 with CommandLine

use of picocli.CommandLine in project dspot by STAMP-project.

the class Main method main.

public static void main(String[] args) {
    UserInput inputConfiguration = new UserInput();
    final CommandLine commandLine = new CommandLine(inputConfiguration);
    commandLine.setUsageHelpWidth(120);
    try {
        commandLine.parseArgs(args);
    } catch (Exception e) {
        e.printStackTrace();
        commandLine.usage(System.err);
        return;
    }
    if (commandLine.isUsageHelpRequested()) {
        commandLine.usage(System.out);
        return;
    }
    if (commandLine.isVersionHelpRequested()) {
        commandLine.printVersionHelp(System.out);
        return;
    }
    if (inputConfiguration.shouldRunExample()) {
        inputConfiguration.configureExample();
    }
    try {
        Checker.preChecking(inputConfiguration);
    } catch (InputErrorException e) {
        e.printStackTrace();
        commandLine.usage(System.err);
        return;
    }
    DSpotState.verbose = inputConfiguration.isVerbose();
    run(inputConfiguration);
}
Also used : CommandLine(picocli.CommandLine) UserInput(eu.stamp_project.prettifier.options.UserInput) InputErrorException(eu.stamp_project.dspot.common.configuration.check.InputErrorException) InputErrorException(eu.stamp_project.dspot.common.configuration.check.InputErrorException) IOException(java.io.IOException)

Aggregations

CommandLine (picocli.CommandLine)68 Test (org.junit.jupiter.api.Test)22 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)20 Copier (org.neo4j.pushtocloud.PushToCloudCommand.Copier)17 ParseResult (picocli.CommandLine.ParseResult)12 Path (java.nio.file.Path)9 Test (org.junit.Test)9 IOException (java.io.IOException)8 Parameters (junitparams.Parameters)8 CommandSpec (picocli.CommandLine.Model.CommandSpec)6 PrintWriter (java.io.PrintWriter)5 DumpCreator (org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator)5 ParameterException (picocli.CommandLine.ParameterException)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Set (java.util.Set)3 OptionSpec (picocli.CommandLine.Model.OptionSpec)3 InputErrorException (eu.stamp_project.dspot.common.configuration.check.InputErrorException)2 File (java.io.File)2 PrintStream (java.io.PrintStream)2