Search in sources :

Example 61 with CommandLine

use of picocli.CommandLine in project neo4j by neo4j.

the class PushToCloudCommandTest method shouldAcceptDumpAsSource.

@Test
void shouldAcceptDumpAsSource() throws Exception {
    // given
    Copier targetCommunicator = mockedTargetCommunicator();
    PushToCloudCommand command = command().copier(targetCommunicator).build();
    // when
    PushToCloudCommand.Uploader uploader = command.makeDumpUploader(this.dump);
    String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
    new CommandLine(command).execute(args);
    // then
    verify(targetCommunicator).checkSize(anyBoolean(), any(), anyLong(), any());
    verify(targetCommunicator).copy(anyBoolean(), any(), any(), eq(uploader.source), eq(false), any());
}
Also used : CommandLine(picocli.CommandLine) Copier(org.neo4j.pushtocloud.PushToCloudCommand.Copier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 62 with CommandLine

use of picocli.CommandLine in project neo4j by neo4j.

the class PushToCloudCommandTest method shouldUseNeo4jAsDefaultUsernameIfUserHitsEnter.

@Test
public void shouldUseNeo4jAsDefaultUsernameIfUserHitsEnter() throws Exception {
    // given
    Copier targetCommunicator = mockedTargetCommunicator();
    PushToCloudConsole console = mock(PushToCloudConsole.class);
    when(console.readLine(anyString(), anyString())).thenReturn("");
    String defaultUsername = "neo4j";
    String password = "super-secret-password";
    PushToCloudCommand command = command().copier(targetCommunicator).console(console).build();
    // when
    String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI, "--password", password.toString() };
    new CommandLine(command).execute(args);
    // then
    verify(console).readLine("%s", format("Neo4j aura username (default: %s):", defaultUsername));
    verify(targetCommunicator).authenticate(anyBoolean(), any(), eq(defaultUsername), eq(password.toCharArray()), anyBoolean());
    verify(targetCommunicator).copy(anyBoolean(), any(), any(), any(), eq(false), any());
}
Also used : CommandLine(picocli.CommandLine) Copier(org.neo4j.pushtocloud.PushToCloudCommand.Copier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 63 with CommandLine

use of picocli.CommandLine in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class VSCommandBase method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) {
    VSCommandFactory factory = new VSCommandFactory(sender);
    CommandLine commandLine = new CommandLine(factory.create(cmdClass), factory);
    registerConverters(commandLine, sender);
    ChatWriter chatOut = new ChatWriter(sender);
    commandLine.setOut(chatOut);
    commandLine.setErr(chatOut);
    args = VSCommandUtil.toProperArgs(args);
    commandLine.execute(args);
}
Also used : CommandLine(picocli.CommandLine)

Example 64 with CommandLine

use of picocli.CommandLine in project loinc2hpo by monarch-initiative.

the class Main method main.

public static void main(String[] args) {
    if (args.length == 0) {
        // if the user doesn't pass any command or option, add -h to show help
        args = new String[] { "-h" };
    }
    CommandLine cline = new CommandLine(new Main()).addSubcommand("annotation-qc", new AnnotationQcCommand()).addSubcommand("stats", new LoincTableCoreStatsCommand());
    cline.setToggleBooleanFlags(false);
    int exitCode = cline.execute(args);
    System.exit(exitCode);
}
Also used : CommandLine(picocli.CommandLine) LoincTableCoreStatsCommand(org.monarchinitiative.loinc2hpocli.command.LoincTableCoreStatsCommand) AnnotationQcCommand(org.monarchinitiative.loinc2hpocli.command.AnnotationQcCommand)

Example 65 with CommandLine

use of picocli.CommandLine in project keycloak by keycloak.

the class Picocli method parseAndRun.

public static void parseAndRun(List<String> cliArgs) {
    CommandLine cmd = createCommandLine(cliArgs);
    if (Environment.isRebuildCheck()) {
        int exitCode = runReAugmentationIfNeeded(cliArgs, cmd);
        exitOnFailure(exitCode, cmd);
        return;
    }
    int exitCode = cmd.execute(cliArgs.toArray(new String[0]));
    exitOnFailure(exitCode, cmd);
}
Also used : CommandLine(picocli.CommandLine)

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