joptsimple.ArgumentAcceptingOptionSpec.defaultsTo()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(123)

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

ArgumentAcceptingOptionSpec.defaultsTo介绍

[英]Specifies a set of default values for the argument of the option that this spec represents.
[中]为该规范表示的选项的参数指定一组默认值。

代码示例

代码示例来源:origin: apache/avro

static OptionSpec<String> compressionCodecOption(OptionParser optParser) {
  return optParser
   .accepts("codec", "Compression codec")
   .withRequiredArg()
   .ofType(String.class)
   .defaultsTo("null");
}

代码示例来源:origin: apache/avro

static OptionSpec<Integer> compressionLevelOption(OptionParser optParser) {
 return optParser
  .accepts("level", "Compression level (only applies to deflate and xz)")
  .withRequiredArg()
  .ofType(Integer.class)
  .defaultsTo(Deflater.DEFAULT_COMPRESSION);
}

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

.withRequiredArg()
.ofType(ClientUpdateCheckMode.class)
.defaultsTo(ClientUpdateCheckMode.AUTO)
.withValuesConvertedBy(new EnumConverter<ClientUpdateCheckMode>(ClientUpdateCheckMode.class)

代码示例来源: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: apache/avro

p.accepts("codec", "Compression codec")
 .withRequiredArg()
 .defaultsTo("null")
 .ofType(String.class);
OptionSet opts = p.parse(args.toArray(new String[0]));

代码示例来源:origin: apache/avro

.withRequiredArg()
 .ofType(Long.class)
 .defaultsTo(new Long(0));
OptionSpec<Long> limitOpt = optParser
 .accepts("limit", "maximum number of records in the outputfile")
 .withRequiredArg()
 .ofType(Long.class)
 .defaultsTo(Long.MAX_VALUE);
OptionSpec<Double> fracOpt = optParser
 .accepts("samplerate", "rate at which records will be collected")
 .withRequiredArg()
 .ofType(Double.class)
 .defaultsTo(new Double(1));

代码示例来源:origin: dieforfree/qart4j

.ofType(String.class)
    .describedAs("log config file path.")
    .defaultsTo("./src/main/config/log4j.properties");
    .defaultsTo("input.png");
acceptsAll(Arrays.asList("u", "url")).withRequiredArg()
    .ofType(String.class)
    .describedAs("URL to encode")
    .defaultsTo("http://free6om.me");
    .defaultsTo(6);
acceptsAll(Arrays.asList("m", "mask")).withRequiredArg()
    .ofType(Integer.class)
    .describedAs("QR mask: 0 - 7")
    .defaultsTo(2);
acceptsAll(Arrays.asList("q", "quiet")).withRequiredArg()
    .ofType(Integer.class)
    .describedAs("QR quiet zone")
    .defaultsTo(2);
acceptsAll(Arrays.asList("r", "rotation")).withRequiredArg()
    .ofType(Integer.class)
    .describedAs("rotation of the image in clockwise: 0 - 3")
    .defaultsTo(0);
acceptsAll(Arrays.asList("z", "size")).withRequiredArg()
    .ofType(Integer.class)
    .describedAs("output QR code size, 0 means don't scale")
    .defaultsTo(0);
acceptsAll(Arrays.asList("cb", "colorBlack")).withOptionalArg()
    .ofType(String.class)

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

.describedAs("zone id")
   .ofType(Integer.class)
   .defaultsTo(-1);
parser.accepts("stores", "store")
   .withRequiredArg()
   .describedAs("number of operations allowed per second per store")
   .ofType(Integer.class)
   .defaultsTo(100);
parser.accepts("delete-all-versions", "Deletes all versions for a given key")
   .withOptionalArg();
   .describedAs("Delete keys belonging to a node")
   .ofType(Integer.class)
   .defaultsTo(-1);
parser.accepts("admin-url", "admin url").withRequiredArg().describedAs("admin url");
parser.accepts("check-keys-exist", "Verify if the number of keys exist")
   .describedAs("Check if the given number of keys exist in the store")
   .ofType(Integer.class)
   .defaultsTo(100);
return parser;

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

/**
 * Return args parser
 *
 * @return program parser
 * */
private static OptionParser getParser() {
  OptionParser parser = new OptionParser();
  parser.accepts("help", "print help information");
  parser.accepts("url", "[REQUIRED] bootstrap URL")
     .withRequiredArg()
     .describedAs("bootstrap-url for the cluster in which a node is to be replaced")
     .ofType(String.class);
  parser.accepts("node", "[REQUIRED] node id.")
     .withRequiredArg()
     .describedAs("node id which needs to be replaced by the new node")
     .ofType(Integer.class);
  parser.accepts("newurl", "[REQUIRED] new bootstrap-url")
     .withRequiredArg()
     .describedAs("bootstrap-url for the new cluster, which will replace the node id")
     .ofType(String.class);
  parser.accepts("skip-restore", "do not restore data from existing machine");
  parser.accepts("parallelism", "parallel data restores.")
     .withRequiredArg()
     .describedAs("number of data restores to happen in parallel")
     .ofType(Integer.class)
     .defaultsTo(3);
  return parser;
}

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

.describedAs("overwriteExistingValue")
   .ofType(Boolean.class)
   .defaultsTo(false);
parser.accepts(IGNORE_SCHEMA_MISMATCH, IGNORE_SCHEMA_WARNING_MESSAGE )
   .withOptionalArg()
   .describedAs("ignoreSchemaMismatch")
   .ofType(Boolean.class)
   .defaultsTo(false);

代码示例来源:origin: adyliu/jafka

.withRequiredArg().describedAs("topic").ofType(String.class);
ArgumentAcceptingOptionSpec<Integer> partitionOpt = parser.accepts("partition", "partition id")//
    .withRequiredArg().describedAs("partition_id").ofType(Integer.class).defaultsTo(0);
ArgumentAcceptingOptionSpec<Long> timeOpt = parser
    .accepts("time",
        "unix time(ms) of the offsets.         -1: lastest; -2: earliest; unix million seconds: offset before this time")//
    .withRequiredArg().describedAs("unix_time").ofType(Long.class).defaultsTo(-1L);
ArgumentAcceptingOptionSpec<Integer> noffsetsOpt = parser.accepts("offsets", "number of offsets returned")//
    .withRequiredArg().describedAs("count").ofType(Integer.class).defaultsTo(1);
OptionSet options = parser.parse(args);
checkRequiredArgs(parser, options, urlOpt, topicOpt, timeOpt);

代码示例来源:origin: adyliu/jafka

ArgumentAcceptingOptionSpec<Integer> countOpt = parser.accepts("c", "max count mesages.")//
    .withRequiredArg().describedAs("count")//
    .ofType(Integer.class).defaultsTo(-1);
ArgumentAcceptingOptionSpec<String> fileOpt = parser.accepts("file", "decode file list")//
    .withRequiredArg().ofType(String.class).describedAs("filepath");

代码示例来源:origin: adyliu/jafka

.withRequiredArg().describedAs("jafka://hostname:port").ofType(String.class);
ArgumentAcceptingOptionSpec<Long> offsetOpt = parser.accepts("offset", "The offset to start consuming from.")//
    .withRequiredArg().describedAs("offset").ofType(Long.class).defaultsTo(0L);

代码示例来源:origin: adyliu/jafka

.withRequiredArg().describedAs("urls").ofType(String.class);
final ArgumentAcceptingOptionSpec<String> groupIdOpt = parser.accepts("group", "The group id to consume on.")//
    .withRequiredArg().describedAs("gid").defaultsTo("console-consumer-" + new Random().nextInt(100000)).ofType(String.class);
ArgumentAcceptingOptionSpec<Integer> fetchSizeOpt = parser.accepts("fetch-size", "The amount of data to fetch in a single request.")//
    .withRequiredArg().describedAs("size").ofType(Integer.class).defaultsTo(1024 * 1024);
ArgumentAcceptingOptionSpec<Integer> socketBufferSizeOpt = parser.accepts("socket-buffer-size", "The size of the tcp RECV size.")//
    .withRequiredArg().describedAs("size").ofType(Integer.class).defaultsTo(2 * 1024 * 1024);
ArgumentAcceptingOptionSpec<Integer> consumerTimeoutMsOpt = parser
    .accepts("consumer-timeout-ms", "consumer throws timeout exception after waiting this much " + "of time without incoming messages")//
    .withRequiredArg().describedAs("prop").ofType(Integer.class).defaultsTo(-1);
ArgumentAcceptingOptionSpec<String> messageFormatterOpt = parser
    .accepts("formatter", "The name of a class to use for formatting jafka messages for display.").withRequiredArg().describedAs("class")
    .ofType(String.class).defaultsTo(NewlineMessageFormatter.class.getName());
ArgumentAcceptingOptionSpec<Integer> autoCommitIntervalOpt = parser
    .accepts("autocommit.interval.ms", "The time interval at which to save the current offset in ms")//
    .withRequiredArg().describedAs("ms").ofType(Integer.class).defaultsTo(10 * 1000);

代码示例来源:origin: adyliu/jafka

.withRequiredArg().describedAs("broker_list").ofType(String.class);
final ArgumentAcceptingOptionSpec<String> messageReaderOpt = parser.accepts("message-encoder", "The class name of the message encoder")//
    .withRequiredArg().describedAs("encoder_class").ofType(String.class).defaultsTo(LineMessageReader.class.getName());

代码示例来源:origin: adyliu/jafka

.withOptionalArg().describedAs("partition").ofType(int.class).defaultsTo(1);
parser.acceptsAll(Arrays.asList("e", "enlarge"), "enlarge partition number if exists");

代码示例来源:origin: org.apache.kafka/kafka_2.10

.withRequiredArg()
  .ofType(String.class)
  .defaultsTo("localhost:9092")
  .describedAs("urls");
zookeeperOption = optionParser.accepts("zookeeper", "Format: HOST:POST")
  .withRequiredArg()
  .ofType(String.class)
  .defaultsTo("localhost:2181")
  .describedAs("url");
inputTopicsOption = optionParser.accepts("input-topics", "Comma-separated list of user input topics")

代码示例来源:origin: org.apache.kafka/kafka

.withRequiredArg()
  .ofType(String.class)
  .defaultsTo("localhost:9092")
  .describedAs("urls");
inputTopicsOption = optionParser.accepts("input-topics", "Comma-separated list of user input topics. For these topics, the tool will reset the offset to the earliest available offset.")

代码示例来源:origin: org.apache.kafka/kafka_2.12

.withRequiredArg()
  .ofType(String.class)
  .defaultsTo("localhost:9092")
  .describedAs("urls");
inputTopicsOption = optionParser.accepts("input-topics", "Comma-separated list of user input topics. For these topics, the tool will reset the offset to the earliest available offset.")

代码示例来源:origin: org.apache.kafka/kafka_2.11

.withRequiredArg()
  .ofType(String.class)
  .defaultsTo("localhost:9092")
  .describedAs("urls");
inputTopicsOption = optionParser.accepts("input-topics", "Comma-separated list of user input topics. For these topics, the tool will reset the offset to the earliest available offset.")

相关文章