ENCODING_OPTION, MessageFormat.format(Messages.CompilerConfigModule_0, ENCODING_OPTION)) .configPath(FILE_ENCODING_NAME) .valueOptional(Messages.CompilerConfigModule_1) .defaultValue(Charset.defaultCharset().displayName()) .build()); "javasource", //$NON-NLS-1$ Messages.CompilerConfigModule_2) .configPath(JAVA_VERSION_NAME) .valueOptional(Messages.CompilerConfigModule_3) .defaultValue(SARLVersion.MINIMAL_JDK_VERSION) .build()); "javacompiler", //$NON-NLS-1$ MessageFormat.format(Messages.CompilerConfigModule_4, JavaCompiler.getDefault().toJsonString())) .configPath(JAVA_COMPILER_NAME) .valueOptional(jcompilerValues) .defaultValue(JavaCompiler.getDefault().toJsonString()) .build()); "writetraces", //$NON-NLS-1$ MessageFormat.format(Messages.CompilerConfigModule_6, Boolean.TRUE)) .configPath(OUTPUT_TRACES_NAME) .valueOptional(trueFalseValues) .defaultValue(Boolean.TRUE.toString()) .build()); "writestorages", //$NON-NLS-1$
Constants.SARL_OUTPUT_DIRECTORY_OPTION, Path.fromPortableString(SARLConfig.FOLDER_SOURCE_GENERATED).toFile().getPath())) .configPath(OUTPUT_PATH_NAME) .valueRequired(Messages.SarlcConfigModule_1) .build()); Constants.JAVA_OUTPUT_DIRECTORY_OPTION, Path.fromPortableString(SARLConfig.FOLDER_BIN).toFile().getPath())) .configPath(CLASS_OUTPUT_PATH_NAME) .valueRequired(Messages.SarlcConfigModule_1) .build()); .configPath(WORKING_PATH_NAME) .valueRequired(Messages.SarlcConfigModule_1) .build()); extend(binder()).addOptions(OptionMetadata.builder( CLASSPATH_LONG_OPTION, cpDescription) .configPath(CLASSPATH_NAME) .valueRequired(Messages.SarlcConfigModule_4) .build(), OptionMetadata.builder( CLASSPATH_SHORT_OPTION, cpDescription) .configPath(CLASSPATH_NAME) .valueRequired(Messages.SarlcConfigModule_4) .build()); "bootclasspath", //$NON-NLS-1$ MessageFormat.format(Messages.SarlcConfigModule_5, File.pathSeparator))
/** * Declares a new CLI option, associating its presence with a configuration resource. This way a single option * can be used to enable a complex configuration. * * @param configResourceId a resource path compatible with {@link io.bootique.resource.ResourceFactory} denoting * a configuration source. E.g. "a/b/my.yml", or "classpath:com/foo/another.yml". * @param name the name of the new CLI option. * @return this extender instance * @since 0.24 * @deprecated since 0.25. The new way of adding an option associated with a config file is by separately declaring * an option and then associating it with one or more configs via {@link #addConfigOnOption(String, String)}. */ @Deprecated public BQCoreModuleExtender addConfigResourceOption(String configResourceId, String name) { contributeOptions().addBinding().toInstance( OptionMetadata.builder(name) .configResource(configResourceId) .valueOptional() .build()); return this; }
/** * Declares a new CLI option, associating it with a config path. The option runtime value is assigned to the * configuration property denoted by the path. Default value provided here will be used if the option is present, * but no value is specified on the command line. * * @param configPath a dot-separated "path" that navigates configuration tree to the desired property. E.g. * "jdbc.myds.password". * @param defaultValue default option value * @param name the name of the new CLI option. * @return this extender instance * @since 0.24 */ public BQCoreModuleExtender addOption(String configPath, String defaultValue, String name) { contributeOptions().addBinding().toInstance( OptionMetadata.builder(name) .configPath(configPath) .defaultValue(defaultValue) .valueOptional() .build()); return this; }
/** * Declares a new CLI option, associating it with a config path. The option runtime value is assigned to the * configuration property denoted by the path. * * @param configPath a dot-separated "path" that navigates configuration tree to the desired property. E.g. * "jdbc.myds.password". * @param name the name of the new CLI option. * @return this extender instance * @since 0.24 */ public BQCoreModuleExtender addOption(String configPath, String name) { contributeOptions().addBinding().toInstance( OptionMetadata.builder(name) .configPath(configPath) .valueRequired() .build()); return this; }
@Override protected void configure() { VariableDecls.extend(binder()).declareVar(IGNORE_WARNINGS_NAME); extend(binder()).addOption(OptionMetadata.builder( "nowarn", Messages.ValidatorConfigModule_0) //$NON-NLS-1$ .configPath(IGNORE_WARNINGS_NAME) .build()); VariableDecls.extend(binder()).declareVar(ALL_WARNINGS_NAME); extend(binder()).addOption(OptionMetadata.builder( "wall", Messages.ValidatorConfigModule_2) //$NON-NLS-1$ .configPath(ALL_WARNINGS_NAME) .build()); VariableDecls.extend(binder()).declareVar(ALL_ERRORS_NAME); extend(binder()).addOption(OptionMetadata.builder( "werror", Messages.ValidatorConfigModule_1) //$NON-NLS-1$ .configPath(ALL_ERRORS_NAME) .build()); }
public Builder addOption(OptionMetadata.Builder optionBuilder) { return addOption(optionBuilder.build()); }
public static Builder builder(String name, String description) { return new Builder().name(name).description(description); }
public Builder valueOptional() { return valueOptional(""); }
public Builder valueRequired() { return valueRequired(""); }
@Override protected void configure() { // Binding a dummy class to trigger eager init of Log4j as // @Provides below can not be invoked eagerly. binder().bind(LogInitTrigger.class).asEagerSingleton(); VariableDecls.extend(binder()).declareVar(LEVEL); extend(binder()).addOption(OptionMetadata.builder( "log", //$NON-NLS-1$ Locale.getString("LOG_OPT", Level.getLabels())) //$NON-NLS-1$ .configPath(LEVEL) .valueRequired(Locale.getString("LEVEL")) //$NON-NLS-1$ .build()); }
OptionMetadata createConfigOption() { return OptionMetadata .builder(CliConfigurationSource.CONFIG_OPTION, "Specifies YAML config location, which can be a file path or a URL.") .valueRequired("yaml_location").build(); }
@Override protected void configure() { extend(binder()) .addOption(OptionMetadata.builder( CompilerCommand.PROGRESS_OPTION_NAME, Messages.CompilerCommandModule_0) .configPath(ProgressBarConfig.ENABLE) .defaultValue(Boolean.TRUE.toString()) .build()); extend(binder()).addCommand(CompilerCommand.class); binder().bindListener(new BindingMatcher(), new LoggerProvisionListener( binder().getProvider(ProgressBarConfig.class))); }
/** * Returns an option representation of this command, that may be used in help generation or exposing the command * in a CLI parser. * * @return option representation of this command. * @since 0.21 */ public OptionMetadata asOption() { // TODO: cache the value? // using getters instead of vars ; some getters have logic return OptionMetadata.builder(getName()).shortName(getShortName()).description(getDescription()).build(); }
public Builder valueRequired() { return valueRequired(""); }
public Builder valueOptional() { return valueOptional(""); }
public Builder addOption(OptionMetadata.Builder optionBuilder) { return addOption(optionBuilder.build()); }
public static Builder builder(String name, String description) { return new Builder().name(name).description(description); }