org.apache.commons.cli.Option.setRequired()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(390)

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

Option.setRequired介绍

[英]Sets whether this Option is mandatory.
[中]设置此选项是否为必填项。

代码示例

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

@Override
public Options buildCommandlineOptions(final Options options) {
  Option opt = new Option("b", "brokerAddr", true, "update which broker");
  opt.setRequired(false);
  options.addOption(opt);
  opt = new Option("c", "clusterName", true, "update which cluster");
  opt.setRequired(false);
  options.addOption(opt);
  return options;
}

代码示例来源:origin: dreamhead/moco

protected final Option envOption() {
  Option opt = new Option("e", true, "environment");
  opt.setType(String.class);
  opt.setRequired(false);
  return opt;
}

代码示例来源:origin: dreamhead/moco

private static Options createShutdownOptions() {
    Options options = new Options();
    Option option = shutdownPortOption();
    option.setRequired(true);
    options.addOption(option);
    return options;
  }
}

代码示例来源:origin: commons-cli/commons-cli

Option left = new Option( "l", "left", false, "go left" );
Option right = new Option( "r", "right", false, "go right" );
Option straight = new Option( "s", "straight", false, "go straight" );
Option forward = new Option( "f", "forward", false, "go forward" );
forward.setRequired( true );
opts.addOption( straight );
assertNotNull(line);
opts.addOption( forward );
args = new String[] { "-s", "-l", "-f" };
line = parser.parse(opts, args);

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

public static Options buildCommandlineOptions(final Options options) {
  Option opt = new Option("h", "help", false, "Print help");
  opt.setRequired(false);
  options.addOption(opt);
  opt =
    new Option("n", "namesrvAddr", true,
      "Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876");
  opt.setRequired(false);
  options.addOption(opt);
  return options;
}

代码示例来源:origin: dreamhead/moco

protected final Option keyStore() {
  Option option = new Option(null, "keystore", true, "Key store password");
  option.setType(String.class);
  option.setRequired(false);
  return option;
}

代码示例来源:origin: commons-cli/commons-cli

/**
 * Add the specified option group.
 *
 * @param group the OptionGroup that is to be added
 * @return the resulting Options instance
 */
public Options addOptionGroup(OptionGroup group)
{
  if (group.isRequired())
  {
    requiredOpts.add(group);
  }
  for (Option option : group.getOptions())
  {
    // an Option cannot be required if it is in an
    // OptionGroup, either the group is required or
    // nothing is required
    option.setRequired(false);
    addOption(option);
    optionGroups.put(option.getKey(), group);
  }
  return this;
}

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

@Override
public Options buildCommandlineOptions(Options options) {
  Option opt = new Option("i", "messageId", true, "unique message ID");
  opt.setRequired(false);
  options.addOption(opt);
  return options;
}

代码示例来源:origin: dreamhead/moco

protected final Option configOption() {
  Option opt = new Option("c", true, "config");
  opt.setType(String.class);
  opt.setRequired(false);
  return opt;
}

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

@Override
public Options buildCommandlineOptions(Options options) {
  Option opt = new Option("t", "topic", true, "topic name");
  opt.setRequired(true);
  options.addOption(opt);
  return options;
}

代码示例来源:origin: dreamhead/moco

protected final Option httpsCertificate() {
  Option option = new Option(null, "https", true, "Https certificate filename");
  option.setType(String.class);
  option.setRequired(false);
  return option;
}

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

@Override
public Options buildCommandlineOptions(Options options) {
  Option opt = new Option("t", "topic", true, "topic name");
  opt.setRequired(true);
  options.addOption(opt);
  opt = new Option("c", "clusterName", true, "delete topic from which cluster");
  opt.setRequired(true);
  options.addOption(opt);
  return options;
}

代码示例来源:origin: dreamhead/moco

public static Option shutdownPortOption() {
    Option opt = new Option("s", true, "shutdown port");
    opt.setType(String.class);
    opt.setRequired(false);
    return opt;
  }
}

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

@Override
public Options buildCommandlineOptions(Options options) {
  Option opt = new Option("b", "brokerAddr", true, "Broker address");
  opt.setRequired(false);
  options.addOption(opt);
  opt = new Option("c", "clusterName", true, "which cluster");
  opt.setRequired(false);
  options.addOption(opt);
  return options;
}

代码示例来源:origin: dreamhead/moco

protected final Option cert() {
  Option option = new Option(null, "cert", true, "Cert password");
  option.setType(String.class);
  option.setRequired(false);
  return option;
}

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

@Override
public Options buildCommandlineOptions(Options options) {
  Option opt = new Option("g", "groupName", true, "consumer group name");
  opt.setRequired(false);
  options.addOption(opt);
  Option optionShowClientIP = new Option("s", "showClientIP", true, "Show Client IP per Queue");
  optionShowClientIP.setRequired(false);
  options.addOption(optionShowClientIP);
  return options;
}

代码示例来源:origin: dreamhead/moco

protected final Option portOption() {
  Option opt = new Option("p", true, "port");
  opt.setType(Number.class);
  opt.setRequired(false);
  return opt;
}

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

@Override
public Options buildCommandlineOptions(Options options) {
  Option opt = new Option("c", "clusterModel", false, "clusterModel");
  opt.setRequired(false);
  options.addOption(opt);
  return options;
}

代码示例来源:origin: dreamhead/moco

protected final Option settingsOption() {
  Option opt = new Option("g", true, "global settings");
  opt.setType(String.class);
  opt.setRequired(false);
  return opt;
}

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

@Override
public Options buildCommandlineOptions(Options options) {
  Option opt = new Option("t", "topic", true, "topic name");
  opt.setRequired(true);
  options.addOption(opt);
  opt = new Option("k", "msgKey", true, "Message Key");
  opt.setRequired(true);
  options.addOption(opt);
  return options;
}

相关文章