use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptOnlyUsernameAndPasswordFromCli.
@Test
public void shouldAcceptOnlyUsernameAndPasswordFromCli() throws IOException, CommandFailedException {
// given
Copier targetCommunicator = mockedTargetCommunicator();
String username = "neo4j";
String password = "abc";
PushToCloudCommand command = command().copier(targetCommunicator).console(PushToCloudConsole.fakeConsole(username, password)).build();
// when
String[] args = { "--dump", dump.toString(), "--username", "neo4jcli", "--password", "passcli", "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
new CommandLine(command).execute(args);
verify(targetCommunicator).authenticate(anyBoolean(), anyString(), eq("neo4jcli"), eq("passcli".toCharArray()), anyBoolean());
}
use of picocli.CommandLine in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptOnlyUsernameAndPasswordFromEnv.
@Test
public void shouldAcceptOnlyUsernameAndPasswordFromEnv() throws Exception {
// given
Copier targetCommunicator = mockedTargetCommunicator();
String username = "neo4j";
String password = "abc";
PushToCloudCommand command = command().copier(targetCommunicator).console(PushToCloudConsole.fakeConsole(username, password)).build();
// when
String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
var environment = Map.of("NEO4J_USERNAME", "neo4jenv", "NEO4J_PASSWORD", "passenv");
new CommandLine(command).setResourceBundle(new MapResourceBundle(environment)).execute(args);
verify(targetCommunicator).authenticate(anyBoolean(), anyString(), eq("neo4jenv"), eq("passenv".toCharArray()), anyBoolean());
}
use of picocli.CommandLine in project liquibase by liquibase.
the class LiquibaseCommandLine method buildPicoCommandLine.
private CommandLine buildPicoCommandLine() {
final CommandLine.Model.CommandSpec rootCommandSpec = CommandLine.Model.CommandSpec.wrapWithoutInspection(null, defaultFactory);
rootCommandSpec.name("liquibase");
configureHelp(rootCommandSpec, true);
rootCommandSpec.subcommandsCaseInsensitive(true);
rootCommandSpec.usageMessage().customSynopsis("liquibase [GLOBAL OPTIONS] [COMMAND] [COMMAND OPTIONS]\nCommand-specific help: \"liquibase <command-name> --help\"").optionListHeading("\nGlobal Options\n").commandListHeading("\nCommands\n");
CommandLine commandLine = new CommandLine(rootCommandSpec, defaultFactory).setCaseInsensitiveEnumValuesAllowed(true).setOptionsCaseInsensitive(true).setUsageHelpAutoWidth(true);
addGlobalArguments(commandLine);
for (CommandDefinition commandDefinition : getCommands()) {
addSubcommand(commandDefinition, commandLine);
}
commandLine.setExecutionExceptionHandler((ex, commandLine1, parseResult) -> LiquibaseCommandLine.this.handleException(ex));
return commandLine;
}
use of picocli.CommandLine in project hazelcast by hazelcast.
the class HazelcastCommandLine method runCommandLine.
static void runCommandLine(Function<ClientConfig, HazelcastInstance> hzClientFn, PrintStream out, PrintStream err, boolean shouldExit, String[] args) {
CommandLine cmd = new CommandLine(new HazelcastCommandLine(hzClientFn, out, err));
cmd.getSubcommands().get("submit").setStopAtPositional(true);
String version = getBuildInfo().getVersion();
cmd.getCommandSpec().usageMessage().header("Hazelcast " + version);
if (args.length == 0) {
cmd.usage(out);
} else {
DefaultExceptionHandler<List<Object>> excHandler = new ExceptionHandler<List<Object>>().useErr(err).useAnsi(Ansi.AUTO);
if (shouldExit) {
excHandler.andExit(1);
}
List<Object> parsed = cmd.parseWithHandlers(new RunAll().useOut(out).useAnsi(Ansi.AUTO), excHandler, args);
// only top command was executed
if (parsed != null && parsed.size() == 1) {
cmd.usage(out);
}
}
}
use of picocli.CommandLine in project hazelcast by hazelcast.
the class HazelcastServerCommandLine method runCommandLine.
private static void runCommandLine(String[] args) {
PrintStream out = System.out;
PrintStream err = System.err;
CommandLine cmd = new CommandLine(new HazelcastServerCommandLine()).setOut(createPrintWriter(out)).setErr(createPrintWriter(err)).setTrimQuotes(true).setExecutionExceptionHandler(new ExceptionHandler());
cmd.execute(args);
String version = getBuildInfo().getVersion();
cmd.getCommandSpec().usageMessage().header("Hazelcast " + version);
if (args.length == 0) {
cmd.usage(out);
}
}
Aggregations