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

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

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

Argument.nargs介绍

[英]Sets the number of command line arguments that should be consumed.

Don't give this method '', '+' or '?'. They are converted to int value and it is not what you expect. For these strings, use #nargs(String).
[中]设置应使用的命令行参数数。
不要给这个方法“
”、“+”或“?”。它们被转换为int值,这不是您所期望的。对于这些字符串,请使用#nargs(String)。

代码示例

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

/**
 * Adds the configuration file argument for the configured command.
 * @param subparser The subparser to register the argument on
 * @return the register argument
 */
protected Argument addFileArgument(Subparser subparser) {
  return subparser.addArgument("file")
          .nargs("?")
          .help("application configuration file");
}

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

@Override
public void configure(Subparser subparser) {
  super.configure(subparser);
  subparser.addArgument("id").nargs(1).help("change set id");
  subparser.addArgument("author").nargs(1).help("author name");
}

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

@Override
public void configure(Subparser subparser) {
  super.configure(subparser);
  subparser.addArgument("output").nargs(1).help("output directory");
}

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

public JobStopCommand(Subparser parser) {
 super(parser);
 parser.help("stop a running job without undeploying it");
 hostsArg = parser.addArgument("hosts")
   .nargs("+")
   .help("The hosts to stop the job on.");
 tokenArg = parser.addArgument("--token")
   .nargs("?")
   .setDefault("")
   .help("Insecure access token");
}

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

public JobStartCommand(Subparser parser) {
 super(parser);
 parser.help("start a stopped job");
 hostsArg = parser.addArgument("hosts")
   .nargs("+")
   .help("The hosts to start the job on.");
 tokenArg = parser.addArgument("--token")
   .nargs("?")
   .setDefault("")
   .help("Insecure access token");
}

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

@Override
public void configure(Subparser subparser) {
  super.configure(subparser);
  subparser.addArgument("tag-name")
      .dest("tag-name")
      .nargs(1)
      .required(true)
      .help("The tag name");
}

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

@Override
public void configure(Subparser subparser) {
  super.configure(subparser);
  subparser.addArgument("-i", "--include-default")
       .action(Arguments.storeTrue())
       .dest("include-default")
       .help("Also render the template with the default name");
  subparser.addArgument("names").nargs("*");
}

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

.nargs("?")
.setDefault("")
.help("Pattern to filter hosts with");
.nargs("?")
.choices(statusChoices.toArray(new String[statusChoices.size()]))
.help("Filter hosts by its status. Valid statuses are: " + statusChoicesString);

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

public JobRemoveCommand(Subparser parser) {
 super(parser);
 parser.help("remove a job");
 tokenArg = parser.addArgument("--token")
   .nargs("?")
   .setDefault("")
   .help("Insecure access token");
 yesArg = parser.addArgument("--yes")
   .action(Arguments.storeTrue())
   .help("Automatically answer 'yes' to the interactive prompt.");
}

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

public JobUndeployCommand(final Subparser parser) {
 super(parser);
 parser.help("undeploy a job from hosts");
 hostsArg = parser.addArgument("hosts")
   .nargs("*")
   .help("The hosts to undeploy the job from.");
 tokenArg = parser.addArgument("--token")
   .nargs("?")
   .setDefault("")
   .help("Insecure access token");
 allArg = parser.addArgument("-a", "--all")
   .action(storeTrue())
   .help("Undeploy from all currently deployed hosts.");
 yesArg = parser.addArgument("--yes")
   .action(storeTrue())
   .help("Automatically answer 'yes' to the interactive prompt.");
}

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

public DeploymentGroupCreateCommand(final Subparser parser) {
 super(parser);
 parser.help("create a deployment group");
 nameArg = parser.addArgument("name")
   .required(true)
   .help("Deployment group name");
 hostSelectorsArg = parser.addArgument("host_selectors")
   .action(append())
   .setDefault(Lists.newArrayList())
   .nargs("+")
   .help("Host selector expression. Hosts matching this expression will be part of the "
      + "deployment-group. Multiple conditions can be specified, separated by spaces (as "
      + "separate arguments). If multiple conditions are given, all must be fulfilled. "
      + "Operators supported are =, !=, in and notin. Example: foo=bar baz!=qux");
 quietArg = parser.addArgument("-q")
   .action(storeTrue())
   .help("only print job id");
}

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

public JobDeployCommand(final Subparser parser) {
 super(parser);
 parser.help("deploy a job to hosts");
 hostsArg = parser.addArgument("hosts")
   .nargs("+")
   .help("The hosts to deploy the job on.");
 tokenArg = parser.addArgument("--token")
   .nargs("?")
   .setDefault("")
   .help("Insecure access token");
 noStartArg = parser.addArgument("--no-start")
   .action(storeTrue())
   .help("Deploy job without starting it.");
 watchArg = parser.addArgument("--watch")
   .action(storeTrue())
   .help("Watch the newly deployed job (like running job watch right after)");
 intervalArg = parser.addArgument("--interval")
   .setDefault(1)
   .help("if --watch is specified, the polling interval, default 1 second");
}

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

parser.addArgument("--member", "-m")
  .type(String.class)
  .nargs("?")
  .required(false)
  .help("The local member identifier, used in intra-cluster communication.");
  .type(addressArgumentType)
  .metavar("HOST:PORT")
  .nargs("?")
  .required(false)
  .help("The address for the local member. If no address is specified, the first public interface will be used.");
parser.addArgument("--host")
  .type(String.class)
  .nargs("?")
  .required(false)
  .help("The host on which this member runs, used for host-aware partition management.");
parser.addArgument("--rack")
  .type(String.class)
  .nargs("?")
  .required(false)
  .help("The rack on which this member runs, used for rack-aware partition management.");
parser.addArgument("--zone")
  .type(String.class)
  .nargs("?")
  .required(false)
  .help("The zone in which this member runs, used for zone-aware partition management.");
  .metavar("CONF|JSON|PROPERTIES")
  .type(File.class)

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

public JobWatchCommand(Subparser parser) {
 super(parser);
 parser.help("watch jobs");
 jobsArg = parser.addArgument("job")
   .help("Job reference");
 intervalArg = parser.addArgument("--interval")
   .type(Integer.class)
   .setDefault(1)
   .help("polling interval, default 1 second");
 prefixesArg = parser.addArgument("hosts")
   .nargs("*")
   .help("The hostname prefixes to watch the job on.");
 exactArg = parser.addArgument("--exact")
   .action(storeTrue())
   .help("Show status of job for every host in hosts");
}

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

public JobListCommand(final Subparser parser) {
 super(parser);
 parser.help("list jobs");
 patternArg = parser.addArgument("pattern")
   .nargs("?")
   .help("Job reference to filter on");
 fullArg = parser.addArgument("-f")
   .action(storeTrue())
   .help("Print full job id's.");
 quietArg = parser.addArgument("-q")
   .action(storeTrue())
   .help("only print job id's");
 deployedArg = parser.addArgument("-y")
   .action(storeTrue())
   .help("only show deployed jobs");
}

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

.nargs("?")
.help("Job name:version[:hash]");
.nargs("?")
.help("Container image");
.nargs("?")
.help("Container hostname");
.nargs("?")
.setDefault(EMPTY_TOKEN)
.help("Insecure access token meant to prevent accidental changes to your job "
.nargs("*")
.help("Command line arguments");
.nargs("?")
.help("Runtime to use with this container.");

代码示例来源:origin: io.dropwizard/dropwizard-core

/**
 * Adds the configuration file argument for the configured command.
 * @param subparser The subparser to register the argument on
 * @return the register argument
 */
protected Argument addFileArgument(Subparser subparser) {
  return subparser.addArgument("file")
          .nargs("?")
          .help("application configuration file");
}

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

.action(append())
.setDefault(new ArrayList<>())
.nargs("+")
.help("Specify environment variables that will pass down to all containers");
.action(append())
.setDefault(new ArrayList<String>())
.nargs("+")
.help("labels to apply to this agent. Labels need to be in the format key=value.");

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

.nargs("?")
.help("Insecure access token meant to prevent accidental changes to your job "
   + "(e.g. undeploys).");

代码示例来源:origin: AsamK/signal-cli

@Override
public void attachToSubparser(final Subparser subparser) {
  subparser.addArgument("-g", "--group")
      .help("Specify the recipient group ID.");
  subparser.addArgument("-n", "--name")
      .help("Specify the new group name.");
  subparser.addArgument("-a", "--avatar")
      .help("Specify a new group avatar image file");
  subparser.addArgument("-m", "--member")
      .nargs("*")
      .help("Specify one or more members to add to the group");
}

相关文章