public static void main(String[] args) { printWelcomeMessage(); CliWrapper cliWrapper = new CliWrapper(); CommandLine commandLine = null; try { commandLine = cliWrapper.parse(args); } catch (ParseException e) { printUsage(cliWrapper); System.out.println(e.getMessage()); System.exit(1); } Configuration configuration = ConfigurationBuilder.initFromFile( commandLine.getOptionValue(CliOption.CONF.getCommandLineParam())); configuration.updateWithCliOptions(commandLine); ConnectorFacade facade = getConnectorFacade(configuration); new Engine(facade, facade, configuration).run(); }
@Test public void shouldExecuteStashReview() throws Exception { // given String[] args = toArgs("-conf %s -pullRequestId %s", SAMPLE_CONFIG, SAMPLE_PULL_REQUEST_ID); // when CommandLine commandLine = fixture.parse(args); // then cliAssert(commandLine) .hasOption(CliOption.PULL_REQUEST_ID.getCommandLineParam()) .withValue(SAMPLE_PULL_REQUEST_ID); }
@Test public void shouldExecuteGerritReview() throws Exception { // given String[] args = toArgs( "-conf %s -changeId %s -revisionId %s", SAMPLE_CONFIG, SAMPLE_CHANGE_ID, SAMPLE_REVISION_ID); // when CommandLine commandLine = fixture.parse(args); // then cliAssert(commandLine).hasOption(CliOption.CONF.getCommandLineParam()).withValue(SAMPLE_CONFIG); cliAssert(commandLine) .hasOption(CliOption.CHANGE_ID.getCommandLineParam()) .withValue(SAMPLE_CHANGE_ID); cliAssert(commandLine) .hasOption(CliOption.REVISION_ID.getCommandLineParam()) .withValue(SAMPLE_REVISION_ID); }
private static void printUsage(@NotNull CliWrapper cliOptions) { System.out.println(HEADER); HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setWidth(WIDTH); helpFormatter.printHelp(SPUTNIK, cliOptions.getOptions(), true); }