Example #1
0
  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();
  }
Example #2
0
  @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);
  }
Example #3
0
  @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);
  }
Example #4
0
 private static void printUsage(@NotNull CliWrapper cliOptions) {
   System.out.println(HEADER);
   HelpFormatter helpFormatter = new HelpFormatter();
   helpFormatter.setWidth(WIDTH);
   helpFormatter.printHelp(SPUTNIK, cliOptions.getOptions(), true);
 }