Codota Logo
OptionMetadata
Code IndexAdd Codota to your IDE (free)

How to use
OptionMetadata
in
io.bootique.meta.application

Best Java code snippets using io.bootique.meta.application.OptionMetadata (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: bootique/bootique

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();
}
origin: bootique/bootique

protected Builder() {
  this.option = new OptionMetadata();
  this.option.valueCardinality = OptionValueCardinality.NONE;
}
origin: bootique/bootique

protected void addOption(OptionParser parser, OptionMetadata option) {
  // ensure non-null description
  String description = Optional.ofNullable(option.getDescription()).orElse("");
  // TODO: how do we resolve short name conflicts?
  List<String> longAndShort = asList(option.getShortName(), option.getName());
  OptionSpecBuilder optionBuilder = parser.acceptsAll(longAndShort, description);
  switch (option.getValueCardinality()) {
    case OPTIONAL:
      ArgumentAcceptingOptionSpec<String> optionSpec = optionBuilder.withOptionalArg().describedAs(option.getValueName());
      if(option.getDefaultValue() != null) {
        optionSpec.defaultsTo(option.getDefaultValue());
      }
      break;
    case REQUIRED:
      optionBuilder.withRequiredArg().describedAs(option.getValueName());
      break;
    default:
      break;
  }
}
origin: io.bootique/bootique

  if (decorator.getOptionName().equals(omd.getName())) {
    overrider = overrider.andThen(new InPlaceResourceOverrider(decorator.getConfigResource().getUrl(),
        parser, singleConfigMerger));
if (omd.getConfigPath() != null) {
  String cliValue = cli.optionString(omd.getName());
  if (cliValue == null) {
    cliValue = omd.getDefaultValue();
    put(omd.getConfigPath(), finalCliValue);
  }}, true, '.'));
if (omd.getConfigResource() != null) {
  overrider = overrider.andThen(new InPlaceResourceOverrider(omd.getConfigResource().getUrl(),
      parser, singleConfigMerger));
origin: bootique/bootique

public HelpOption(OptionMetadata option) {
  this.option = Objects.requireNonNull(option);
  this.shortNameAllowed = true;
  this.longNameAllowed = option.getName().length() > 1;
}
origin: bootique/bootique

public void add(OptionMetadata option) {
  HelpOption ho = new HelpOption(option);
  byShortName.computeIfAbsent(ho.getOption().getShortName(), sn -> new ArrayList<HelpOption>()).add(ho);
}
origin: bootique/bootique

private void checkNameDuplicates(Collection<OptionMetadata> options) {
  if (options.size() > 1) {
    Set<String> distinctNames = new HashSet<>();
    options.forEach(om -> {
      if (!distinctNames.add(om.getName())) {
        throw new RuntimeException("Duplicate option declaration for '" + om.getName() + "'");
      }
    });
  }
}
origin: bootique/bootique

  o.setShortNameAllowed(false);
} else if (shortCounter[0]) {
  throw new IllegalStateException("Conflicting short option name: " + o.getOption().getShortName());
} else {
  shortCounter[0] = true;
origin: bootique/bootique

options.forEach(o -> {
  String valueName = o.getOption().getValueName();
  if (valueName == null || valueName.length() == 0) {
    valueName = "val";
  if (o.isShortNameAllowed()) {
    parts.add("-");
    parts.add(String.valueOf(o.getOption().getShortName()));
    switch (o.getOption().getValueCardinality()) {
      case REQUIRED:
        parts.add(" ");
    parts.add(o.getOption().getName());
    switch (o.getOption().getValueCardinality()) {
      case REQUIRED:
        parts.add("=");
  String description = o.getOption().getDescription();
  if (description != null) {
    out.printDescription(description);
origin: bootique/bootique

/**
 * 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();
}
origin: bootique/bootique

@Override
public int compareTo(HelpOption o) {
  return option.getName().compareTo(o.getOption().getName());
}
origin: io.bootique/bootique

public void add(OptionMetadata option) {
  HelpOption ho = new HelpOption(option);
  byShortName.computeIfAbsent(ho.getOption().getShortName(), sn -> new ArrayList<HelpOption>()).add(ho);
}
origin: io.bootique/bootique

protected Builder() {
  this.option = new OptionMetadata();
  this.option.valueCardinality = OptionValueCardinality.NONE;
}
origin: io.bootique/bootique

protected void addOption(OptionParser parser, OptionMetadata option) {
  // ensure non-null description
  String description = Optional.ofNullable(option.getDescription()).orElse("");
  // TODO: how do we resolve short name conflicts?
  List<String> longAndShort = asList(option.getShortName(), option.getName());
  OptionSpecBuilder optionBuilder = parser.acceptsAll(longAndShort, description);
  switch (option.getValueCardinality()) {
    case OPTIONAL:
      optionBuilder.withOptionalArg().describedAs(option.getValueName());
      break;
    case REQUIRED:
      optionBuilder.withRequiredArg().describedAs(option.getValueName());
    default:
      break;
  }
}
origin: io.bootique/bootique

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();
}
origin: bootique/bootique

private OptionMetadata findMetadata(OptionSpec<?> option) {
  List<String> optionNames = option.options();
  // TODO: allow lookup of option metadata by name to avoid linear scans...
  // Though we are dealing with small collection, so shouldn't be too horrible.
  for (OptionMetadata omd : optionMetadata) {
    if (optionNames.contains(omd.getName())) {
      return omd;
    }
  }
  // this was likely a command, not an option.
  return null;
}
origin: io.bootique/bootique

  o.setShortNameAllowed(false);
} else if (shortCounter[0]) {
  throw new IllegalStateException("Conflicting short option name: " + o.getOption().getShortName());
} else {
  shortCounter[0] = true;
origin: io.bootique/bootique

options.forEach(o -> {
  String valueName = o.getOption().getValueName();
  if (valueName == null || valueName.length() == 0) {
    valueName = "val";
  if (o.isShortNameAllowed()) {
    parts.add("-");
    parts.add(String.valueOf(o.getOption().getShortName()));
    switch (o.getOption().getValueCardinality()) {
      case REQUIRED:
        parts.add(" ");
    parts.add(o.getOption().getName());
    switch (o.getOption().getValueCardinality()) {
      case REQUIRED:
        parts.add("=");
  String description = o.getOption().getDescription();
  if (description != null) {
    out.printDescription(description);
origin: io.bootique/bootique

/**
 * 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;
}
origin: bootique/bootique

if (decorator.getOptionName().equals(omd.getName())) {
  overrider = overrider.andThen(new InPlaceResourceOverrider(decorator.getConfigResource().getUrl(),
      parser, singleConfigMerger));
if (pathDecorator.getOptionName().equals(omd.getName())) {
  String cliValue = cli.optionString(omd.getName());
  overrider = overrider.andThen(new InPlaceMapOverrider(
      singletonMap(pathDecorator.getConfigPath(), cliValue)
io.bootique.meta.applicationOptionMetadata

Javadoc

A descriptor of a command-line option.

Most used methods

  • builder
  • <init>
  • getConfigPath
    Returns an optional configuration path associated with this option.
  • getConfigResource
    Returns an optional resource associated with this option.
  • getDefaultValue
    Returns the default value for this option. I.e. the value that will be used if the option is provide
  • getDescription
  • getName
  • getShortName
  • getValueCardinality
  • getValueName

Popular in Java

  • Finding current android device location
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • startActivity (Activity)
  • InputStreamReader (java.io)
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes
  • MessageFormat (java.text)
    MessageFormat provides a means to produce concatenated messages in language-neutral way. Use this to
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JButton (javax.swing)
  • JLabel (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now