.ofType(ClientUpdateCheckMode.class) .defaultsTo(ClientUpdateCheckMode.AUTO) .withValuesConvertedBy(new EnumConverter<ClientUpdateCheckMode>(ClientUpdateCheckMode.class)
Elasticsearch() { super("starts elasticsearch", () -> {}); // we configure logging later so we override the base class from configuring logging versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") .availableUnless(versionOption) .withRequiredArg() .withValuesConvertedBy(new PathConverter()); quietOption = parser.acceptsAll(Arrays.asList("q", "quiet"), "Turns off standard output/error streams logging in console") .availableUnless(versionOption) .availableUnless(daemonizeOption); }
/** * <p>Specifies a type to which arguments of this spec's option are to be converted.</p> * * <p>JOpt Simple accepts types that have either:</p> * * <ol> * <li>a public static method called {@code valueOf} which accepts a single argument of type {@link String} * and whose return type is the same as the class on which the method is declared. The {@code java.lang} * primitive wrapper classes have such methods.</li> * * <li>a public constructor which accepts a single argument of type {@link String}.</li> * </ol> * * <p>This class converts arguments using those methods in that order; that is, {@code valueOf} would be invoked * before a one-{@link String}-arg constructor would.</p> * * <p>Invoking this method will trump any previous calls to this method or to * {@link #withValuesConvertedBy(ValueConverter)}.</p> * * @param <T> represents the runtime class of the desired option argument type * @param argumentType desired type of arguments to this spec's option * @return self, so that the caller can add clauses to the fluent interface sentence * @throws NullPointerException if the type is {@code null} * @throws IllegalArgumentException if the type does not have the standard conversion methods */ public final <T> ArgumentAcceptingOptionSpec<T> ofType( Class<T> argumentType ) { return withValuesConvertedBy( findConverter( argumentType ) ); }
/** * <p>Specifies a type to which arguments of this spec's option are to be converted.</p> * * <p>JOpt Simple accepts types that have either:</p> * * <ol> * <li>a public static method called {@code valueOf} which accepts a single argument of type {@link String} * and whose return type is the same as the class on which the method is declared. The {@code java.lang} * primitive wrapper classes have such methods.</li> * * <li>a public constructor which accepts a single argument of type {@link String}.</li> * </ol> * * <p>This class converts arguments using those methods in that order; that is, {@code valueOf} would be invoked * before a one-{@link String}-arg constructor would.</p> * * <p>Invoking this method will trump any previous calls to this method or to * {@link #withValuesConvertedBy(ValueConverter)}. * * @param <T> represents the runtime class of the desired option argument type * @param argumentType desired type of arguments to this spec's option * @return self, so that the caller can add clauses to the fluent interface sentence * @throws NullPointerException if the type is {@code null} * @throws IllegalArgumentException if the type does not have the standard conversion methods */ public final <T> ArgumentAcceptingOptionSpec<T> ofType( Class<T> argumentType ) { return withValuesConvertedBy( findConverter( argumentType ) ); }
/** * <p>Specifies a type to which arguments of this spec's option are to be converted.</p> * * <p>JOpt Simple accepts types that have either:</p> * * <ol> * <li>a public static method called {@code valueOf} which accepts a single argument of type {@link String} * and whose return type is the same as the class on which the method is declared. The {@code java.lang} * primitive wrapper classes have such methods.</li> * * <li>a public constructor which accepts a single argument of type {@link String}.</li> * </ol> * * <p>This class converts arguments using those methods in that order; that is, {@code valueOf} would be invoked * before a one-{@link String}-arg constructor would.</p> * * <p>Invoking this method will trump any previous calls to this method or to * {@link #withValuesConvertedBy(ValueConverter)}.</p> * * @param <T> represents the runtime class of the desired option argument type * @param argumentType desired type of arguments to this spec's option * @return self, so that the caller can add clauses to the fluent interface sentence * @throws NullPointerException if the type is {@code null} * @throws IllegalArgumentException if the type does not have the standard conversion methods */ public final <T> ArgumentAcceptingOptionSpec<T> ofType( Class<T> argumentType ) { return withValuesConvertedBy( findConverter( argumentType ) ); }
/** * <p>Specifies a type to which arguments of this spec's option are to be converted.</p> * * <p>JOpt Simple accepts types that have either:</p> * * <ol> * <li>a public static method called {@code valueOf} which accepts a single argument of type {@link String} * and whose return type is the same as the class on which the method is declared. The {@code java.lang} * primitive wrapper classes have such methods.</li> * * <li>a public constructor which accepts a single argument of type {@link String}.</li> * </ol> * * <p>This class converts arguments using those methods in that order; that is, {@code valueOf} would be invoked * before a one-{@link String}-arg constructor would.</p> * * <p>Invoking this method will trump any previous calls to this method or to * {@link #withValuesConvertedBy(ValueConverter)}. * * @param <T> represents the runtime class of the desired option argument type * @param argumentType desired type of arguments to this spec's option * @return self, so that the caller can add clauses to the fluent interface sentence * @throws NullPointerException if the type is {@code null} * @throws IllegalArgumentException if the type does not have the standard conversion methods */ public final <T> ArgumentAcceptingOptionSpec<T> ofType( Class<T> argumentType ) { return withValuesConvertedBy( findConverter( argumentType ) ); }
/** * <p>Specifies a type to which arguments of this spec's option are to be converted.</p> * * <p>JOpt Simple accepts types that have either:</p> * * <ol> * <li>a public static method called {@code valueOf} which accepts a single argument of type {@link String} * and whose return type is the same as the class on which the method is declared. The {@code java.lang} * primitive wrapper classes have such methods.</li> * * <li>a public constructor which accepts a single argument of type {@link String}.</li> * </ol> * * <p>This class converts arguments using those methods in that order; that is, {@code valueOf} would be invoked * before a one-{@link String}-arg constructor would.</p> * * <p>Invoking this method will trump any previous calls to this method or to * {@link #withValuesConvertedBy(ValueConverter)}. * * @param <T> represents the runtime class of the desired option argument type * @param argumentType desired type of arguments to this spec's option * @return self, so that the caller can add clauses to the fluent interface sentence * @throws NullPointerException if the type is {@code null} * @throws IllegalArgumentException if the type does not have the standard conversion methods */ public final <T> ArgumentAcceptingOptionSpec<T> ofType( Class<T> argumentType ) { return withValuesConvertedBy( findConverter( argumentType ) ); }
private static ArgumentAcceptingOptionSpec<Class<? extends IExternalConverter>> makeConverterDisabledSpec(OptionParser optionParser) { return optionParser .acceptsAll(Arrays.asList( CommandDescription.ARGUMENT_LONG_DISABLED_CONVERTER, CommandDescription.ARGUMENT_SHORT_DISABLED_CONVERTER), CommandDescription.DESCRIPTION_CONTEXT_DISABLED_CONVERTER ) .withRequiredArg() .describedAs(CommandDescription.DESCRIPTION_ARGUMENT_DISABLED_CONVERTER) .withValuesConvertedBy(new ExternalConverterValueConverter()); }
private static ArgumentAcceptingOptionSpec<Class<? extends IExternalConverter>> makeConverterEnabledSpec(OptionParser optionParser) { return optionParser .acceptsAll(Arrays.asList( CommandDescription.ARGUMENT_LONG_ENABLED_CONVERTER, CommandDescription.ARGUMENT_SHORT_ENABLED_CONVERTER), CommandDescription.DESCRIPTION_CONTEXT_ENABLED_CONVERTER ) .withRequiredArg() .describedAs(CommandDescription.DESCRIPTION_ARGUMENT_ENABLED_CONVERTER) .withValuesConvertedBy(new ExternalConverterValueConverter()); }
private static ArgumentAcceptingOptionSpec<Level> makeLogLevelSpec(OptionParser optionParser) { return optionParser .acceptsAll(Arrays.asList( CommandDescription.ARGUMENT_LONG_LOG_LEVEL, CommandDescription.ARGUMENT_SHORT_LOG_LEVEL), CommandDescription.DESCRIPTION_CONTEXT_LOG_LEVEL ) .withRequiredArg() .describedAs(CommandDescription.DESCRIPTION_ARGUMENT_LOG_LEVEL) .withValuesConvertedBy(new LogLevelValueConverter()) .defaultsTo(Level.WARN); }
private static ArgumentAcceptingOptionSpec<Level> makeLogLevelSpec(OptionParser optionParser) { return optionParser .acceptsAll(Arrays.asList( CommandDescription.ARGUMENT_LONG_LOG_LEVEL, CommandDescription.ARGUMENT_SHORT_LOG_LEVEL), CommandDescription.DESCRIPTION_CONTEXT_LOG_LEVEL ) .withRequiredArg() .describedAs(CommandDescription.DESCRIPTION_ARGUMENT_LOG_LEVEL) .withValuesConvertedBy(new LogLevelValueConverter()) .defaultsTo(Level.WARN); }
.acceptsAll(Arrays.asList("q", "quote"), "CSV field quote character") .withOptionalArg() .withValuesConvertedBy(new ValueConverterCharacter()) .acceptsAll(Arrays.asList("d", "delimiter"), "CSV field delimiter") .withRequiredArg() .withValuesConvertedBy(new ValueConverterCharacter()) .defaultsTo(defaultCsvFormat.getDelimiter()) .withValuesConvertedBy(new ValueConverterCharacter())
.acceptsAll(Arrays.asList("q", "quote"), "CSV field quote character") .withOptionalArg() .withValuesConvertedBy(new ValueConverterCharacter()) .acceptsAll(Arrays.asList("d", "delimiter"), "CSV field delimiter") .withRequiredArg() .withValuesConvertedBy(new ValueConverterCharacter()) .defaultsTo(defaultCsvFormat.getDelimiter()) .withValuesConvertedBy(new ValueConverterCharacter())
Elasticsearch() { super("starts elasticsearch", () -> {}); // we configure logging later so we override the base class from configuring logging versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") .availableUnless(versionOption) .withRequiredArg() .withValuesConvertedBy(new PathConverter()); quietOption = parser.acceptsAll(Arrays.asList("q", "quiet"), "Turns off standard output/error streams logging in console") .availableUnless(versionOption) .availableUnless(daemonizeOption); }
Elasticsearch() { super("starts elasticsearch"); versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") .availableUnless(versionOption) .withRequiredArg() .withValuesConvertedBy(new PathConverter()); quietOption = parser.acceptsAll(Arrays.asList("q", "quiet"), "Turns off standard ouput/error streams logging in console") .availableUnless(versionOption) .availableUnless(daemonizeOption); }
Elasticsearch() { super("starts elasticsearch", () -> {}); // we configure logging later so we override the base class from configuring logging versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"), "Creates a pid file in the specified path on start") .availableUnless(versionOption) .withRequiredArg() .withValuesConvertedBy(new PathConverter()); quietOption = parser.acceptsAll(Arrays.asList("q", "quiet"), "Turns off standard output/error streams logging in console") .availableUnless(versionOption) .availableUnless(daemonizeOption); }
void processArguments(Environment env, Consumer<OptionParser> parserConsumer, BiConsumer<OptionSet, BiFunction<String, OptionSet, ITransformationService.OptionResult>> resultConsumer) { final OptionParser parser = new OptionParser(); parser.allowsUnrecognizedOptions(); profileOption = parser.accepts("version", "The version we launched with").withRequiredArg(); gameDirOption = parser.accepts("gameDir", "Alternative game directory").withRequiredArg().withValuesConvertedBy(new PathConverter(PathProperties.DIRECTORY_EXISTING)); assetsDirOption = parser.accepts("assetsDir", "Assets directory").withRequiredArg().withValuesConvertedBy(new PathConverter(PathProperties.DIRECTORY_EXISTING)); minecraftJarOption = parser.accepts("minecraftJar", "Path to minecraft jar").withRequiredArg().withValuesConvertedBy(new PathConverter(PathProperties.READABLE)).withValuesSeparatedBy(','); launchTarget = parser.accepts("launchTarget", "LauncherService target to launch").withRequiredArg(); parserConsumer.accept(parser); nonOption = parser.nonOptions(); this.optionSet = parser.parse(this.args); env.computePropertyIfAbsent(IEnvironment.Keys.VERSION.get(), s -> this.optionSet.valueOf(profileOption)); env.computePropertyIfAbsent(IEnvironment.Keys.GAMEDIR.get(), f -> this.optionSet.valueOf(gameDirOption)); env.computePropertyIfAbsent(IEnvironment.Keys.ASSETSDIR.get(), f -> this.optionSet.valueOf(assetsDirOption)); env.computePropertyIfAbsent(IEnvironment.Keys.LAUNCHTARGET.get(), f -> this.optionSet.valueOf(launchTarget)); resultConsumer.accept(this.optionSet, this::optionResults); }
OptionSpecBuilder bld = parser.acceptsAll(arg.getNames(), arg.doc); if (arg.isFlag()) { bld.withOptionalArg().withValuesConvertedBy(new StrictBooleanConverter()); } else { bld.withRequiredArg();
+ " of update, use an empty value to remove a key: -cp solr.collection=") .withRequiredArg() .withValuesConvertedBy(new StringPairConverter()) .describedAs("key=value"); + LifecycleState.ACTIVE + ", " + LifecycleState.DELETE_REQUESTED) .withRequiredArg() .withValuesConvertedBy(new EnumConverter<LifecycleState>(LifecycleState.class)) .defaultsTo(LifecycleState.DEFAULT) .describedAs("state"); + ", " + IncrementalIndexingState.DO_NOT_SUBSCRIBE) .withRequiredArg() .withValuesConvertedBy(new EnumConverter<IncrementalIndexingState>(IncrementalIndexingState.class)) .defaultsTo(IncrementalIndexingState.DEFAULT) .describedAs("state"); + "\"direct write\" mode (scanning over all records and sending the results to a live solr cluster).")) .withRequiredArg() .withValuesConvertedBy(new EnumConverter<BatchIndexingState>(BatchIndexingState.class)) .defaultsTo(BatchIndexingState.DEFAULT) .describedAs("state");
+ " of update, use an empty value to remove a key: -cp solr.collection=") .withRequiredArg() .withValuesConvertedBy(new StringPairConverter()) .describedAs("key=value"); + LifecycleState.ACTIVE + ", " + LifecycleState.DELETE_REQUESTED) .withRequiredArg() .withValuesConvertedBy(new EnumConverter<LifecycleState>(LifecycleState.class)) .defaultsTo(LifecycleState.DEFAULT) .describedAs("state"); + ", " + IncrementalIndexingState.DO_NOT_SUBSCRIBE) .withRequiredArg() .withValuesConvertedBy(new EnumConverter<IncrementalIndexingState>(IncrementalIndexingState.class)) .defaultsTo(IncrementalIndexingState.DEFAULT) .describedAs("state"); + "\"direct write\" mode (scanning over all records and sending the results to a live solr cluster).")) .withRequiredArg() .withValuesConvertedBy(new EnumConverter<BatchIndexingState>(BatchIndexingState.class)) .defaultsTo(BatchIndexingState.DEFAULT) .describedAs("state");