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());
}
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());
}
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);
}
use of picocli.CommandLine in project groovy by apache.
the class FileSystemCompiler method commandLineCompile.
/**
* Same as main(args) except that exceptions are thrown out instead of causing
* the VM to exit and the lookup for .groovy files can be controlled
*/
public static void commandLineCompile(String[] args, boolean lookupUnnamedFiles) throws Exception {
CompilationOptions options = new CompilationOptions();
CommandLine parser = configureParser(options);
ParseResult parseResult = parser.parseArgs(args);
if (CommandLine.printHelpIfRequested(parseResult)) {
return;
}
displayStackTraceOnError = options.printStack;
CompilerConfiguration configuration = options.toCompilerConfiguration();
// Load the file name list
String[] filenames = options.generateFileNames();
boolean fileNameErrors = filenames == null;
if (!fileNameErrors && (filenames.length == 0)) {
parser.usage(System.err);
return;
}
fileNameErrors = fileNameErrors && !validateFiles(filenames);
if (!fileNameErrors) {
doCompilation(configuration, null, filenames, lookupUnnamedFiles);
}
}
use of picocli.CommandLine in project jgnash by ccavanaugh.
the class jGnashFx method main.
public static void main(final String[] args) {
if (OS.getJavaVersion() < 11f) {
System.err.println(ResourceUtils.getString("Message.JVM11"));
System.err.println(ResourceUtils.getString("Message.Version") + " " + System.getProperty("java.version") + "\n");
// show a swing based dialog
JOptionPane.showMessageDialog(null, ResourceUtils.getString("Message.JVM11"), ResourceUtils.getString("Title.Error"), JOptionPane.ERROR_MESSAGE);
return;
}
// Register the default exception handler
Thread.setDefaultUncaughtExceptionHandler(new StaticUIMethods.ExceptionHandler());
final CommandLine commandLine = new CommandLine(new CommandLineOptions());
commandLine.setToggleBooleanFlags(false);
commandLine.setUsageHelpWidth(80);
try {
final ParseResult pr = commandLine.parseArgs(args);
final CommandLineOptions options = commandLine.getCommand();
if (CommandLine.printHelpIfRequested(pr)) {
System.exit(0);
}
// check for bad server file and hostName combination... can't do both
if (serverFile != null && options.hostName != null) {
commandLine.usage(System.err, Help.Ansi.AUTO);
System.exit(1);
}
configureLogging();
if (options.uninstall) {
PortablePreferences.deleteUserPreferences();
System.exit(0);
}
// System.getProperties().put(EncryptionManager.ENCRYPTION_FLAG, Boolean.toString(options.ssl));
// System.getProperties().put("ssl", Boolean.toString(options.ssl));
port = options.port;
hostName = options.hostName;
password = options.password;
if (options.shutdown) {
if (hostName == null) {
hostName = EngineFactory.LOCALHOST;
}
MessageBus.getInstance().shutDownRemoteServer(hostName, port + 1, password);
System.exit(0);
}
if (options.verbose) {
System.setProperty("javafx.verbose", "true");
}
if (options.portableFile != null) {
PortablePreferences.initPortablePreferences(options.portableFile.getAbsolutePath());
} else if (options.portable) {
PortablePreferences.initPortablePreferences(null);
}
if (options.zeroArgFile != null && options.zeroArgFile.exists()) {
jGnashFx.dataFile = options.zeroArgFile;
}
if (options.dataFile != null && options.dataFile.exists()) {
jGnashFx.dataFile = options.dataFile;
}
if (options.serverFile != null && options.serverFile.exists()) {
jGnashFx.serverFile = options.serverFile;
startServer();
} else {
setupNetworking();
launch(args);
}
} catch (final Exception e) {
logSevere(jGnashFx.class, e);
commandLine.usage(System.err, Help.Ansi.AUTO);
System.exit(1);
}
}
Aggregations