net.sourceforge.argparse4j.inf.Namespace.getBoolean()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中net.sourceforge.argparse4j.inf.Namespace.getBoolean()方法的一些代码示例,展示了Namespace.getBoolean()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace.getBoolean()方法的具体详情如下:
包路径:net.sourceforge.argparse4j.inf.Namespace
类名称:Namespace
方法名:getBoolean

Namespace.getBoolean介绍

[英]Returns attribute as Boolean with given attribute name dest.
[中]返回具有给定属性名dest的布尔属性。

代码示例

代码示例来源:origin: spotify/helios

public Boolean getInhibitMetrics() {
 return fromNullable(options.getBoolean(noMetricsArg.getDest())).or(false);
}

代码示例来源:origin: spotify/helios

public Boolean getNoZooKeeperRegistration() {
 return fromNullable(options.getBoolean(noZooKeeperRegistrationArg.getDest())).or(false);
}

代码示例来源:origin: dropwizard/dropwizard

@Override
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
  final Boolean verbose = namespace.getBoolean("verbose");
  liquibase.reportStatus(verbose == null ? false : verbose,
              getContext(namespace),
              new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
}

代码示例来源:origin: spotify/helios

public boolean getZooKeeperEnableAcls() {
 return options.getBoolean(zooKeeperEnableAcls.getDest());
}

代码示例来源:origin: dropwizard/dropwizard

@Override
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
  final boolean list = firstNonNull(namespace.getBoolean("list"), false);
  final boolean release = firstNonNull(namespace.getBoolean("release"), false);
  if (list == release) {
    throw new IllegalArgumentException("Must specify either --list or --force-release");
  } else if (list) {
    liquibase.reportLocks(printStream);
  } else {
    liquibase.forceReleaseLocks();
  }
}

代码示例来源:origin: dropwizard/dropwizard

@Override
public void run(Namespace namespace,
        Liquibase liquibase) throws Exception {
  final String context = getContext(namespace);
  if (namespace.getBoolean("all")) {
    if (namespace.getBoolean("dry-run")) {
      liquibase.changeLogSync(context, new OutputStreamWriter(printStream, StandardCharsets.UTF_8));
    } else {
      liquibase.changeLogSync(context);
    }
  } else {
    if (namespace.getBoolean("dry-run")) {
      liquibase.markNextChangeSetRan(context, new OutputStreamWriter(printStream, StandardCharsets.UTF_8));
    } else {
      liquibase.markNextChangeSetRan(context);
    }
  }
}

代码示例来源:origin: dropwizard/dropwizard

@Override
  protected void run(Bootstrap<HelloWorldConfiguration> bootstrap,
            Namespace namespace,
            HelloWorldConfiguration configuration) throws Exception {
    final Template template = configuration.buildTemplate();

    if (namespace.getBoolean("include-default")) {
      LOGGER.info("DEFAULT => {}", template.render(Optional.empty()));
    }

    for (String name : namespace.<String>getList("names")) {
      for (int i = 0; i < 1000; i++) {
        LOGGER.info("{} => {}", name, template.render(Optional.of(name)));
        Thread.sleep(1000);
      }
    }
  }
}

代码示例来源:origin: signalapp/Signal-Server

@Override
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
 liquibase.reportStatus(namespace.getBoolean("verbose"),
             getContext(namespace),
             new OutputStreamWriter(System.out, Charsets.UTF_8));
}

代码示例来源:origin: signalapp/Signal-Server

@Override
public void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception {
 if (MoreObjects.firstNonNull(namespace.getBoolean("ca"), false)) runCaCommand();
 else                                                                  runCertificateCommand(namespace);
}

代码示例来源:origin: dropwizard/dropwizard

final Set<Class<? extends DatabaseObject>> compareTypes = new HashSet<>();
if (isTrue(namespace.getBoolean("columns"))) {
  compareTypes.add(Column.class);
if (isTrue(namespace.getBoolean("data"))) {
  compareTypes.add(Data.class);
if (isTrue(namespace.getBoolean("foreign-keys"))) {
  compareTypes.add(ForeignKey.class);
if (isTrue(namespace.getBoolean("indexes"))) {
  compareTypes.add(Index.class);
if (isTrue(namespace.getBoolean("primary-keys"))) {
  compareTypes.add(PrimaryKey.class);
if (isTrue(namespace.getBoolean("sequences"))) {
  compareTypes.add(Sequence.class);
if (isTrue(namespace.getBoolean("tables"))) {
  compareTypes.add(Table.class);
if (isTrue(namespace.getBoolean("unique-constraints"))) {
  compareTypes.add(UniqueConstraint.class);
if (isTrue(namespace.getBoolean("views"))) {
  compareTypes.add(View.class);

代码示例来源:origin: dropwizard/dropwizard

@Override
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
  final String context = getContext(namespace);
  final Integer count = namespace.getInt("count");
  final boolean dryRun = namespace.getBoolean("dry-run") == null ? false : namespace.getBoolean("dry-run");
  if (count != null) {
    if (dryRun) {
      liquibase.update(count, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.update(count, context);
    }
  } else {
    if (dryRun) {
      liquibase.update(context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.update(context);
    }
  }
}

代码示例来源:origin: spotify/helios

@Override
 int run(final Namespace options, final HeliosClient client, final PrintStream out,
     final boolean json, final BufferedReader stdin)
   throws ExecutionException, InterruptedException {

  final List<String> masters = client.listMasters().get();
  final boolean full = options.getBoolean(fullArg.getDest());

  final SortedSet<String> sortedMasters = Sets.newTreeSet();

  if (json) {
   for (final String host : masters) {
    sortedMasters.add(formatHostname(full, host));
   }
   out.println(Json.asPrettyStringUnchecked(sortedMasters));
  } else {
   for (final String host : masters) {
    out.println(formatHostname(full, host));
   }
  }

  return 0;
 }
}

代码示例来源:origin: dropwizard/dropwizard

@Override
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
  final String tag = namespace.getString("tag");
  final Integer count = namespace.getInt("count");
  final Date date = namespace.get("date");
  final boolean dryRun = namespace.getBoolean("dry-run") == null ? false : namespace.getBoolean("dry-run");
  final String context = getContext(namespace);
  if (Stream.of(tag, count, date).filter(Objects::nonNull).count() != 1) {
    throw new IllegalArgumentException("Must specify either a count, a tag, or a date.");
  }
  if (count != null) {
    if (dryRun) {
      liquibase.rollback(count, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.rollback(count, context);
    }
  } else if (tag != null) {
    if (dryRun) {
      liquibase.rollback(tag, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.rollback(tag, context);
    }
  } else {
    if (dryRun) {
      liquibase.rollback(date, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.rollback(date, context);
    }
  }
}

代码示例来源:origin: spotify/helios

public LoggingConfig getLoggingConfig() {
 return new LoggingConfig(options.getInt(verboseArg.getDest()),
   options.getBoolean(syslogArg.getDest()),
   (File) options.get(logconfigArg.getDest()),
   options.getBoolean(noLogSetupArg.getDest()));
}

代码示例来源:origin: spotify/helios

@Override
int run(final Namespace options, final HeliosClient client, final PrintStream out,
    final boolean json, final BufferedReader stdin)
  throws ExecutionException, InterruptedException {
 final String name = options.getString(nameArg.getDest());
 final boolean full = options.getBoolean(fullArg.getDest());
 return run0(client, out, json, name, full);
}

代码示例来源:origin: spotify/helios

BufferedReader stdin) throws ExecutionException, InterruptedException, IOException {
final String name = options.getString(nameArg.getDest());
final boolean full = options.getBoolean(fullArg.getDest());
final Integer interval = options.getInt(intervalArg.getDest());
final DateTimeFormatter formatter = DateTimeFormat.forPattern(DATE_TIME_PATTERN);

代码示例来源:origin: spotify/helios

@Override
int run(final Namespace options, final List<TargetAndClient> clients,
    final PrintStream out, final boolean json, final BufferedReader stdin)
  throws ExecutionException, InterruptedException, IOException {
 final boolean exact = options.getBoolean(exactArg.getDest());
 final List<String> prefixes = options.getList(prefixesArg.getDest());
 final String jobIdString = options.getString(jobsArg.getDest());
 final List<ListenableFuture<Map<JobId, Job>>> jobIdFutures = Lists.newArrayList();
 for (final TargetAndClient cc : clients) {
  jobIdFutures.add(cc.getClient().jobs(jobIdString));
 }
 final Set<JobId> jobIds = Sets.newHashSet();
 for (final ListenableFuture<Map<JobId, Job>> future : jobIdFutures) {
  jobIds.addAll(future.get().keySet());
 }
 watchJobsOnHosts(out, exact, prefixes, jobIds, options.getInt(intervalArg.getDest()),
   clients);
 return 0;
}

代码示例来源:origin: signalapp/Signal-Server

@Override
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
 final String context = getContext(namespace);
 final Integer count = namespace.getInt("count");
 final Boolean dryRun = namespace.getBoolean("dry-run");
 if (count != null) {
  if (dryRun) {
   liquibase.update(count, context, new OutputStreamWriter(System.out, Charsets.UTF_8));
  } else {
   liquibase.update(count, context);
  }
 } else {
  if (dryRun) {
   liquibase.update(context, new OutputStreamWriter(System.out, Charsets.UTF_8));
  } else {
   liquibase.update(context);
  }
 }
}

代码示例来源:origin: spotify/helios

public static HeliosClient getClient(final Target target, final PrintStream err,
                   final String username, final Namespace options) {
 List<URI> endpoints = Collections.emptyList();
 try {
  endpoints = target.getEndpointSupplier().get();
 } catch (Exception ignore) {
  // TODO (dano): Nasty. Refactor target to propagate resolution failure in a checked manner.
 }
 if (endpoints.size() == 0) {
  err.println("Failed to resolve helios master in " + target);
  return null;
 }
 //argparse4j converts names like "--http-timeout" to dests of "http_timeout"
 final int httpTimeout = parseTimeout(options, "http_timeout",
   HTTP_TIMEOUT_ENV_VAR, DEFAULT_HTTP_TIMEOUT_SECS);
 final int retryTimeout = parseTimeout(options, "retry_timeout",
   TOTAL_TIMEOUT_ENV_VAR, DEFAULT_TOTAL_TIMEOUT_SECS);
 log.debug("using HeliosClient httpTimeout={}, retryTimeout={}", httpTimeout, retryTimeout);
 return HeliosClient.newBuilder()
   .setEndpointSupplier(Endpoints.of(target.getEndpointSupplier()))
   .setHttpTimeout(httpTimeout, TimeUnit.SECONDS)
   .setRetryTimeout(retryTimeout, TimeUnit.SECONDS)
   .setSslHostnameVerification(!options.getBoolean("insecure"))
   .setGoogleCredentialsEnabled(options.getBoolean("google_credentials"))
   .setUser(username)
   .build();
}

代码示例来源:origin: spotify/helios

protected FastForwardConfig ffwdConfig(final Namespace options) {
  if (!options.getBoolean(ffwdEnabled.getDest())) {
   return null;
  }

  return new FastForwardConfig(
    Optional.ofNullable(options.getString(ffwdAddress.getDest())),
    options.getInt(ffwdInterval.getDest()),
    options.getString(ffwdMetricKey.getDest()));
 }
}

相关文章