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

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

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

Argument.setConst介绍

[英]Sets constant values that are not read from the command line but are required for the various actions.

The const value defaults to null.
[中]设置不从命令行读取但各种操作所需的常量值。
const值默认为null。

代码示例

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

.type(OutputFormat.class)
   .action(Arguments.storeConst())
   .setConst(OutputFormat.CSV_GZIP)
   .dest("output_format")
   .help("specify output file type");
  .dest("crossfold_mode")
  .action(Arguments.storeConst())
  .setConst("partition-users")
  .help("Partition users into K partitions (the default)");
mode.addArgument("--partition-entities")
  .dest("crossfold_mode")
  .action(Arguments.storeConst())
  .setConst("partition-entities")
  .help("Partition entities into K partitions");
mode.addArgument("--partition-ratings")
  .dest("crossfold_mode")
  .action(Arguments.storeConst())
  .setConst("partition-ratings")
  .help("Partition ratings into K partitions");
mode.addArgument("--sample-entities")
  .dest("crossfold_mode")
  .action(Arguments.storeConst())
  .setConst("sample-entities")
  .help("Create K samples of entities");
mode.addArgument("--sample-users")
  .dest("crossfold_mode")
  .action(Arguments.storeConst())
  .setConst("sample-users")

代码示例来源:origin: com.palantir.atlasdb/atlasdb-dropwizard-bundle

@VisibleForTesting
static void addOptionToParser(Subparser parser, OptionMetadata option) {
  if (option.isHidden()) {
    return;
  }
  List<String> sortedOptions = option.getOptions().stream()
      .sorted((first, second) -> Integer.compareUnsigned(first.length(), second.length()))
      .collect(Collectors.toList());
  String longOption = Iterables.getLast(sortedOptions);
  Argument arg = parser.addArgument(sortedOptions.toArray(new String[] {}))
      .required(option.isRequired())
      .help(option.getDescription())
      .dest(longOption);
  if (option.getArity() == 0) {
    arg.action(Arguments.storeConst());
    arg.setConst(AtlasDbCommandUtils.ZERO_ARITY_ARG_CONSTANT);
  } else {
    arg.nargs(option.getArity());
  }
}

代码示例来源:origin: com.palantir.atlasdb/atlasdb-dropwizard-bundle

protected void addOfflineParameter(Subparser subparser) {
  subparser.addArgument(AtlasDbCommandUtils.OFFLINE_COMMAND_ARG_NAME)
      .help("run this cli offline")
      .dest(AtlasDbCommandUtils.OFFLINE_COMMAND_ARG_NAME)
      .required(false)
      .action(Arguments.storeConst())
      .setConst(AtlasDbCommandUtils.ZERO_ARITY_ARG_CONSTANT);
}

代码示例来源:origin: adamkewley/jobson

@Override
public void configure(Subparser subparser) {
  subparser.addArgument(DEMO_ARG_NAME)
      .dest(DEMO_ARG_NAME)
      .action(Arguments.storeConst())
      .setConst(true)
      .setDefault(false)
      .help("Generate application with a demo spec");
}

代码示例来源:origin: bazaarvoice/jersey-hmac-auth

contentTypes.addArgument("-J", "--json").dest("content_type").setConst("application/json").action(storeConst()).help("Specifies application/json in the Content-Type request header");

代码示例来源:origin: neo4j/cypher-shell

.help("exit and report failure on first error when reading from file (this is the default behavior)")
    .dest("fail-behavior")
    .setConst(FAIL_FAST)
    .action(new StoreConstArgumentAction());
failGroup.addArgument("--fail-at-end")
    .help("exit and report failures at end of input when reading from file")
    .dest("fail-behavior")
    .setConst(FAIL_AT_END)
    .action(new StoreConstArgumentAction());
parser.setDefault("fail-behavior", FAIL_FAST);

代码示例来源:origin: kiselev-dv/gazetteer

.setConst("none").setDefault("bz2")
  .help("Use with \"osm_file -\" allow to read compressed stream from STDIN.");
  .nargs("?").setConst(Boolean.TRUE);
  .choices(Slicer.sliceTypes).nargs("*").setDefault("all").setConst("all");
slice.addArgument("--x10").setConst(Boolean.TRUE)
  .setDefault(Boolean.FALSE).action(new StoreTrueArgumentAction())
  .help("Slice ten times thinner stripes");
slice.addArgument("--skip-interpolation").setConst(Boolean.TRUE)
  .setDefault(Boolean.FALSE).action(new StoreTrueArgumentAction())
  .help("Do not parse addr:interpolation lines");
slice.addArgument("--disk-index").setConst(Boolean.TRUE)
  .setDefault(Boolean.FALSE).action(new StoreTrueArgumentAction())
  .help("Use off RAM index for points/ways/relations build");
slice.addArgument("--skip-point-to-boundary-merge").setConst(Boolean.TRUE)
  .setDefault(Boolean.FALSE).action(new StoreTrueArgumentAction())
  .help("Don't merge place point to it's boundary");
slice.addArgument("--skip-nearest-city").setConst(Boolean.TRUE)
  .setDefault(Boolean.FALSE).action(new StoreTrueArgumentAction())
  .help("Use only polygonal boundaries for cities");
  .nargs("?").setConst(Boolean.TRUE)
  .help("Search for translated address rows. \n"

代码示例来源:origin: reposense/RepoSense

.metavar("PATH")
.type(new ReportFolderArgumentType())
.setConst(EMPTY_PATH)
.help("Starts a server to display the dashboard in the provided directory."
    + "If used as a flag (with no argument), "

代码示例来源:origin: com.github.fracpete/rsync4j-core

.help("Verbose mode.")
 .action(Arguments.storeConst())
 .setConst(1)
 .setDefault(0);
parser.addArgument("-vv")
 .help("Very verbose mode.")
 .action(Arguments.storeConst())
 .setConst(2)
 .setDefault(0);
parser.addArgument("-vvv")
 .help("Very, very verbose mode.")
 .action(Arguments.storeConst())
 .setConst(3)
 .setDefault(0);
parser.addArgument("-W")

代码示例来源:origin: com.github.fracpete/rsync4j-core

.help("Verbose mode.")
 .action(Arguments.storeConst())
 .setConst(1)
 .setDefault(0);
parser.addArgument("-vv")
 .help("Very verbose mode.")
 .action(Arguments.storeConst())
 .setConst(2)
 .setDefault(0);
parser.addArgument("-vvv")
 .help("Very, very verbose mode.")
 .action(Arguments.storeConst())
 .setConst(3)
 .setDefault(0);
parser.addArgument("-W")

相关文章