static OptionArg<Boolean> createGuiOpt(Builder builder) { return Option.builder("g", ArgumentParser.booleanParser()) .longName("show-gui") .description( "Starts the gui for each simulation when 'true' is supplied, hides " + "it when 'false' is supplied. By default the gui is ", builder.showGui ? "" : "not", " shown. The gui can only be shown if the computation is performed " + "locally and the number of threads is set to 1.") .build(); }
static OptionArg<List<SimulationProperty>> createOrderingOption( Builder builder) { return Option.builder("o", ArgumentParser.enumListParser("list", SimulationProperty.class)) .longName("ordering") .description( "Sets the ordering of simulations as specified by simulation " + "properties, default: ", Joiner.on(",").join(builder.experimentOrdering), ". All options must be specified exactly once.") .build(); }
static OptionArg<List<String>> createIncludeOption( Map<String, Path> pathMap, Builder builder) { final StringBuilder sb = new StringBuilder(); printPathOptions(pathMap, sb); sb.append("This option can not be used together with --exclude."); return Option .builder("i", ArgumentParser.stringListParser()) .longName("include") .description(sb.toString()) .build(); }
.add(Option.builder("a", ArgumentParser.longParser()).build(), list, new ArgHandler<List<Object>, Long>() { .add(Option.builder("aa", ArgumentParser.longListParser()) .longName("add-all") .description("Add all longs, and then some. Please note that " .add(Option.builder("asl", ArgumentParser.stringListParser()).build(), list, new ArgHandler<List<Object>, List<String>>() { .add(Option.builder("z").build(), list, dummyHandler()) .closeGroup() .add(Option.builder("as", ArgumentParser.stringParser()).build(), list, new ArgHandler<List<Object>, String>() { .addHelpOption("h", "help", "Print this message") .add(Option.builder("failure", ArgumentParser .booleanParser()) .build(), list, .add(Option.builder("happy", ArgumentParser.booleanParser()).build(), list, new ArgHandler<List<Object>, Boolean>() {
static OptionArg<String> createDryRunOpt(Builder builder) { return Option.builder("dr", ArgumentParser.stringParser()) .longName("dry-run") .description( "Will perform a 'dry run' of the experiment without doing any" + " actual simulations. A detailed description of the " + "experiment setup will be printed. If an additional " + "argument 'v' or 'verbose' is supplied, more details of" + " the experiment will be printed.") .setOptionalArgument() .build(); }
static OptionArg<List<String>> createIncludeOpt( Map<String, MASConfiguration> configMap) { return Option.builder("i", ArgumentParser.prefixedIntList(CONFIG_PREFIX)) .longName("include") .description( "The following configurations can be included in the experiment " + "setup:", createConfigString(configMap), "This option can not be used together with --exclude.") .build(); }
static OptionArg<Long> createSeedOption(Experiment.Builder builder) { return Option.builder(S, ArgumentParser.longParser()) .longName("seed") .description( "Sets the master random seed, default: ", builder.masterSeed, ".") .build(); }
/** * Create a parser for {@link Enum}s. * @param name The name for the value of the option (typically the enum name). * @param enumClass The class of the enum. * @param <T> The class of the enum. * @return A new {@link ArgumentParser} for instances of the specified enum. */ public static <T extends Enum<T>> ArgumentParser<T> enumParser(String name, Class<T> enumClass) { return asParser(name, Enums.stringConverter(enumClass)); }
/** * Create a parser for lists of {@link Enum}s. * @param name The name for the values of the option (typically the enum name * with 'list' appended). * @param enumClass The class of the enum. * @param <T> The class of the enum. * @return A new {@link ArgumentParser} for lists of instances of the * specified enum. */ public static <T extends Enum<T>> ArgumentParser<List<T>> enumListParser( String name, Class<T> enumClass) { return asListParser(name, Enums.stringConverter(enumClass)); }
/** * Tests correct parsing of enum. */ @Test public void testEnum() { final List<TestEnum> consumer = new ArrayList<>(); final Menu m = Menu.builder() .addHelpOption("h", "help", "Hi") .add(Option.builder("e", ArgumentParser.enumParser("testenum", TestEnum.class)).build(), consumer, new AddToListHandler<TestEnum>()) .build(); m.execute("-e", "A"); assertThat(consumer) .containsExactly(TestEnum.A); consumer.clear(); m.execute("-e", "B"); assertThat(consumer) .containsExactly(TestEnum.B); consumer.clear(); testFail(m, "e", CauseType.INVALID_ARG_FORMAT, "-e", "a"); testFail(m, "e", CauseType.INVALID_ARG_FORMAT, "-e", "NON_EXISTING_ENUM"); assertThat(consumer).isEmpty(); }
static OptionArg<String> createDryRunOpt(Builder builder) { return Option.builder("dr", ArgumentParser.stringParser()) .longName("dry-run") .description( "Will perform a 'dry run' of the experiment without doing any" + " actual simulations. A detailed description of the " + "experiment setup will be printed. If an additional " + "argument 'v' or 'verbose' is supplied, more details of" + " the experiment will be printed.") .setOptionalArgument() .build(); }
static OptionArg<List<String>> createExcludeOpt( Map<String, MASConfiguration> configMap) { return Option.builder("e", ArgumentParser.prefixedIntList(CONFIG_PREFIX)) .longName("exclude") .description( "The following configurations can be excluded from the experiment" + " setup:", createConfigString(configMap), "This option can not be used together with --include.") .build(); }
static OptionArg<Long> createWarmupOption(Builder builder) { return Option.builder("w", ArgumentParser.longParser()) .longName("warmup") .description( "Sets the warmup period (in ms) of the experiment, default: ", builder.warmupPeriodMs, " ms.") .build(); }
static OptionArg<String> createFilterOption(Builder ref) { return Option .builder("f", ArgumentParser.stringParser()) .longName("filter") .description( "Sets a filter of which paths to include. The filter is a string " + "of the form 'syntax:pattern', where 'syntax' is either " + "'glob' or 'regex'. The current filter is '" + ref.pathPredicate + "', there are " + ref.getNumberOfFiles() + " files that satisfy this filter. For more information about" + " the supported syntax please review the documentation of the" + " java.nio.file.FileSystem.getPathMatcher(String) method.") .build(); }
static OptionArg<List<String>> createExcludeOption( Map<String, Path> pathMap, Builder builder) { final StringBuilder sb = new StringBuilder(); printPathOptions(pathMap, sb); sb.append("This option can not be used together with --include."); return Option.builder("e", ArgumentParser.stringListParser()) .longName("exclude") .description(sb.toString()) .build(); }
static OptionArg<List<String>> createExcludeOpt( Map<String, MASConfiguration> configMap) { return Option.builder("e", ArgumentParser.prefixedIntList(CONFIG_PREFIX)) .longName("exclude") .description( "The following configurations can be excluded from the experiment" + " setup:", createConfigString(configMap), "This option can not be used together with --include.") .build(); }
static OptionArg<Long> createSeedOption(Experiment.Builder builder) { return Option.builder(S, ArgumentParser.longParser()) .longName("seed") .description( "Sets the master random seed, default: ", builder.masterSeed, ".") .build(); }
static OptionArg<List<SimulationProperty>> createOrderingOption( Builder builder) { return Option.builder("o", ArgumentParser.enumListParser("list", SimulationProperty.class)) .longName("ordering") .description( "Sets the ordering of simulations as specified by simulation " + "properties, default: ", Joiner.on(",").join(builder.experimentOrdering), ". All options must be specified exactly once.") .build(); }
static OptionArg<Boolean> createGuiOpt(Builder builder) { return Option.builder("g", ArgumentParser.booleanParser()) .longName("show-gui") .description( "Starts the gui for each simulation when 'true' is supplied, hides " + "it when 'false' is supplied. By default the gui is ", builder.showGui ? "" : "not", " shown. The gui can only be shown if the computation is performed " + "locally and the number of threads is set to 1.") .build(); }
static OptionArg<String> createFilterOption(Builder ref) { return Option .builder("f", ArgumentParser.stringParser()) .longName("filter") .description( "Sets a filter of which paths to include. The filter is a string " + "of the form 'syntax:pattern', where 'syntax' is either " + "'glob' or 'regex'. The current filter is '" + ref.pathPredicate + "', there are " + ref.getNumberOfFiles() + " files that satisfy this filter. For more information about" + " the supported syntax please review the documentation of the" + " java.nio.file.FileSystem.getPathMatcher(String) method.") .build(); }