use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.
the class DataStaxBulkLoaderTest method should_process_json_long_options.
@ParameterizedTest
@MethodSource
void should_process_json_long_options(String settingName, String settingValue, Object expected) throws Exception {
Config result = new CommandLineParser("load", "--" + settingName, settingValue).parse().getConfig();
assertThat(result.getAnyRef(settingName)).isEqualTo(expected);
}
use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.
the class DataStaxBulkLoaderTest method should_accept_escaped_double_quote_in_complex_type.
@Test
void should_accept_escaped_double_quote_in_complex_type() throws Exception {
// double quotes should be provided escaped as valid HOCON
Config result = new CommandLineParser("load", "--codec.booleanStrings", "[\"foo\\\"bar\"]").parse().getConfig();
assertThat(result.getStringList("dsbulk.codec.booleanStrings")).containsExactly("foo\"bar");
}
use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.
the class DataStaxBulkLoaderTest method should_process_csv_long_options.
@ParameterizedTest
@MethodSource
void should_process_csv_long_options(String settingName, String settingValue, Object expected) throws Exception {
Config result = new CommandLineParser("load", "--" + settingName, settingValue).parse().getConfig();
assertThat(result.getAnyRef(settingName)).isEqualTo(expected);
}
use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.
the class DataStaxBulkLoader method run.
@NonNull
public ExitStatus run() {
Workflow workflow = null;
try {
AnsiConfigurator.configureAnsi(args);
CommandLineParser parser = new CommandLineParser(args);
ParsedCommandLine result = parser.parse();
Config config = result.getConfig();
workflow = result.getWorkflowProvider().newWorkflow(config);
WorkflowThread workflowThread = new WorkflowThread(workflow);
Runtime.getRuntime().addShutdownHook(new CleanupThread(workflow, workflowThread));
// start the workflow and wait for its completion
workflowThread.start();
workflowThread.join();
return workflowThread.getExitStatus();
} catch (GlobalHelpRequestException e) {
HelpEmitter.emitGlobalHelp(e.getConnectorName());
return STATUS_OK;
} catch (SectionHelpRequestException e) {
try {
HelpEmitter.emitSectionHelp(e.getSectionName(), e.getConnectorName());
return STATUS_OK;
} catch (Exception e2) {
LOGGER.error(e2.getMessage(), e2);
return STATUS_CRASHED;
}
} catch (VersionRequestException e) {
// Use the OS charset
PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out, Charset.defaultCharset())));
pw.println(WorkflowUtils.getBulkLoaderNameAndVersion());
pw.flush();
return STATUS_OK;
} catch (Throwable t) {
return ErrorHandler.handleUnexpectedError(workflow, t);
}
}
use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.
the class DataStaxBulkLoaderTest method should_accept_escaped_double_quote.
@Test
void should_accept_escaped_double_quote() throws Exception {
// double quotes should be provided escaped as valid HOCON
Config result = new CommandLineParser("load", "--connector.csv.escape", "\\\"").parse().getConfig();
assertThat(result.getString("dsbulk.connector.csv.escape")).isEqualTo("\"");
}
Aggregations