public static void main()

in tools/benchmark-cli/src/main/java/org/logstash/benchmark/cli/Main.java [65:165]


    public static void main(final String... args) throws IOException, NoSuchAlgorithmException {
        final OptionParser parser = new OptionParser();
        final OptionSpecBuilder gitbuilder =
            parser.accepts(UserInput.GIT_VERSION_PARAM, UserInput.GIT_VERSION_HELP);
        final OptionSpecBuilder localbuilder =
            parser.accepts(UserInput.LOCAL_VERSION_PARAM, UserInput.LOCAL_VERSION_HELP);
        final OptionSpecBuilder distributionbuilder =
            parser.accepts(
                UserInput.DISTRIBUTION_VERSION_PARAM, UserInput.DISTRIBUTION_VERSION_HELP
            );
        final OptionSpec<String> git = gitbuilder.requiredUnless(
            UserInput.DISTRIBUTION_VERSION_PARAM, UserInput.LOCAL_VERSION_PARAM
        ).availableUnless(UserInput.DISTRIBUTION_VERSION_PARAM, UserInput.LOCAL_VERSION_PARAM)
            .withRequiredArg().ofType(String.class).forHelp();
        final OptionSpec<String> distribution = distributionbuilder
            .requiredUnless(UserInput.LOCAL_VERSION_PARAM, UserInput.GIT_VERSION_PARAM)
            .availableUnless(
                UserInput.LOCAL_VERSION_PARAM, UserInput.GIT_VERSION_PARAM
            ).withRequiredArg().ofType(String.class).forHelp();
        final OptionSpec<String> local = localbuilder.requiredUnless(
            UserInput.DISTRIBUTION_VERSION_PARAM, UserInput.GIT_VERSION_PARAM)
            .availableUnless(UserInput.DISTRIBUTION_VERSION_PARAM, UserInput.GIT_VERSION_PARAM)
            .withRequiredArg().ofType(String.class).forHelp();
        final OptionSpec<String> testcase = parser.accepts(
            UserInput.TEST_CASE_PARAM, UserInput.TEST_CASE_HELP
        ).withRequiredArg().ofType(String.class).defaultsTo(GeneratorToStdout.IDENTIFIER).forHelp();
        final OptionSpec<File> testcaseconfig = parser.accepts(
                UserInput.TEST_CASE_CONFIG_PARAM, UserInput.TEST_CASE_CONFIG_HELP
        ).withRequiredArg().ofType(File.class).forHelp();
        final OptionSpec<File> testcasedata = parser.accepts(
            UserInput.TEST_CASE_DATA_PARAM, UserInput.TEST_CASE_DATA_HELP
            ).withRequiredArg().ofType(File.class).forHelp();
        final OptionSpec<File> pwd = parser.accepts(
            UserInput.WORKING_DIRECTORY_PARAM, UserInput.WORKING_DIRECTORY_HELP
        ).withRequiredArg().ofType(File.class).defaultsTo(UserInput.WORKING_DIRECTORY_DEFAULT)
            .forHelp();
        final OptionSpec<String> esout = parser.accepts(
            UserInput.ES_OUTPUT_PARAM, UserInput.ES_OUTPUT_HELP
        ).withRequiredArg().ofType(String.class).defaultsTo(UserInput.ES_OUTPUT_DEFAULT).forHelp();
        final OptionSpec<Integer> repeats = parser.accepts(
            UserInput.REPEAT_PARAM, UserInput.REPEAT_PARAM_HELP
        ).withRequiredArg().ofType(Integer.class).defaultsTo(1).forHelp();
        final OptionSpec<Integer> workers = parser.accepts(
            UserInput.LS_WORKER_THREADS, UserInput.LS_WORKER_THREADS_HELP
        ).withRequiredArg().ofType(Integer.class)
            .defaultsTo(UserInput.LS_WORKER_THREADS_DEFAULT).forHelp();
        final OptionSpec<Integer> batchsize = parser.accepts(
            UserInput.LS_BATCH_SIZE, UserInput.LS_BATCH_SIZE_HELP
        ).withRequiredArg().ofType(Integer.class)
            .defaultsTo(UserInput.LS_BATCHSIZE_DEFAULT).forHelp();
        final OptionSet options;
        try {
            options = parser.parse(args);
        } catch (final OptionException ex) {
            parser.printHelpOn(System.out);
            throw ex;
        }
        final LsVersionType type;
        final String version;
        if (options.has(distribution)) {
            type = LsVersionType.DISTRIBUTION;
            version = options.valueOf(distribution);
        } else if (options.has(git)) {
            type = LsVersionType.GIT;
            version = options.valueOf(git);
        } else {
            type = LsVersionType.LOCAL;
            version = options.valueOf(local);
        }
        final Properties settings = loadSettings();
        settings.setProperty(
            LsBenchSettings.INPUT_DATA_REPEAT, String.valueOf(options.valueOf(repeats))
        );

        Path testCaseConfigPath = null;
        Path testCaseDataPath = null;
        if (options.valueOf(testcase).equals("custom")) {
            if (options.has(testcaseconfig)) {
                testCaseConfigPath = options.valueOf(testcaseconfig).toPath();
            }
            else {
                throw new IllegalArgumentException("Path to Test Case Config must be provided");
            }
            if (options.has(testcasedata)) {
                testCaseDataPath = options.valueOf(testcasedata).toPath();
            }
        } else {
            if (options.has(testcaseconfig) || options.has(testcasedata)) {
                throw new IllegalArgumentException("Path to Test Case Config or Data can only be used with Custom Test Case");
        }
    }

        final BenchmarkMeta runConfig = new BenchmarkMeta(
            options.valueOf(testcase), testCaseConfigPath, testCaseDataPath, version, type, options.valueOf(workers),
            options.valueOf(batchsize)
        );
        execute(
            new UserOutput(System.out), settings, options.valueOf(pwd).toPath(), runConfig,
            options.valueOf(esout)
        );
    }