当前位置: 首页>>代码示例>>Java>>正文


Java Option类代码示例

本文整理汇总了Java中org.apache.commons.cli.Option的典型用法代码示例。如果您正苦于以下问题:Java Option类的具体用法?Java Option怎么用?Java Option使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Option类属于org.apache.commons.cli包,在下文中一共展示了Option类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildCommandlineOptions

import org.apache.commons.cli.Option; //导入依赖的package包/类
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("g", "groupName", true, "consumer group name");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:9,代码来源:ConsumerProgressSubCommand.java

示例2: main

import org.apache.commons.cli.Option; //导入依赖的package包/类
public static void main(String[] args) throws ParseException {
  Options options = new Options();
  Option nameOption = new Option("n", true, "Name to resolve");
  nameOption.setRequired(true);
  options.addOption(nameOption);
  CommandLineParser parser = new BasicParser();
  CommandLine cmd = parser.parse(options, args);

  BasicConfigurator.configure();
  Logger.getRootLogger().setLevel(Level.DEBUG);
  PodCIDRToNodeMapping plugin = new PodCIDRToNodeMapping();
  Configuration conf = new Configuration();
  plugin.setConf(conf);

  String nameToResolve = cmd.getOptionValue(nameOption.getOpt());
  List<String> networkPathDirs = plugin.resolve(Lists.newArrayList(nameToResolve));
  log.info("Resolved " + nameToResolve + " to " + networkPathDirs);
}
 
开发者ID:apache-spark-on-k8s,项目名称:kubernetes-HDFS,代码行数:19,代码来源:PodCIDRToNodeMapping.java

示例3: initCli

import org.apache.commons.cli.Option; //导入依赖的package包/类
/**
 * Initialize the command line interface.
 */
private static void initCli() {
	options = new Options();
	options.addOption("b", BYGONE, false, "Signals a historical conversion");
	options.addOption("v", SKIP_VALIDATION, false, "Skip validations");
	options.addOption("d", SKIP_DEFAULTS, false,"Skip defaulted transformations");
	options.addOption("h", HELP, false,"This help message");

	Option templateScope = Option.builder("t")
			.longOpt(TEMPLATE_SCOPE)
			.argName("scope1,scope2,...")
			.hasArg()
			.desc("Comma delimited scope values to use for context. Valid values: "
					+ Arrays.toString(QrdaScope.getNames()))
			.build();
	options.addOption(templateScope);

	formatter = new HelpFormatter();
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:22,代码来源:ConversionEntry.java

示例4: getOptions

import org.apache.commons.cli.Option; //导入依赖的package包/类
private static Options getOptions() {
  Options options = new Options();
  options.addOption("b", "bind", true,
      "Address to bind the Thrift server to. [default: 0.0.0.0]");
  options.addOption("p", "port", true, "Port to bind to [default: " + DEFAULT_LISTEN_PORT + "]");
  options.addOption("f", "framed", false, "Use framed transport");
  options.addOption("c", "compact", false, "Use the compact protocol");
  options.addOption("w", "workers", true, "How many worker threads to use.");
  options.addOption("h", "help", false, "Print help information");
  options.addOption(null, "infoport", true, "Port for web UI");
  options.addOption("t", READ_TIMEOUT_OPTION, true,
    "Amount of time in milliseconds before a server thread will timeout " +
    "waiting for client to send data on a connected socket. Currently, " +
    "only applies to TBoundedThreadPoolServer");
  OptionGroup servers = new OptionGroup();
  servers.addOption(
      new Option("nonblocking", false, "Use the TNonblockingServer. This implies the framed transport."));
  servers.addOption(new Option("hsha", false, "Use the THsHaServer. This implies the framed transport."));
  servers.addOption(new Option("threadpool", false, "Use the TThreadPoolServer. This is the default."));
  options.addOptionGroup(servers);
  return options;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:ThriftServer.java

示例5: buildOptions

import org.apache.commons.cli.Option; //导入依赖的package包/类
public static Options buildOptions() {
    Options options = new Options();
    optionLCI.setArgs(1);
    optionLCI.setArgs(1);
    optionUCI.setArgs(1);
    optionUCO.setArgs(1);
    optionK.setArgs(Option.UNLIMITED_VALUES);
    optionK.setRequired(true);
    options.addOption(optionLCI);
    options.addOption(optionLCO);
    options.addOption(optionUCI);
    options.addOption(optionUCO);
    options.addOption(optionD);
    options.addOption(optionR);
    options.addOption(optionK);
    options.addOption(optionS);
    return options;
}
 
开发者ID:hwding,项目名称:pdf-unstamper,代码行数:19,代码来源:OptionManager.java

示例6: createOption

import org.apache.commons.cli.Option; //导入依赖的package包/类
/**
 * Small helper for creating some of the long parameter settings we frequently
 * use here.
 *
 * @param optName       name of the parameter/option
 * @param description   description for the help text
 * @param isRequired    whether this parameter is strictly required
 * @param unlimitedArgs whether it supports multiple arguments, default is on argument
 */
public static Option createOption(String optName, String description,
    boolean isRequired, boolean unlimitedArgs) {

  Option.Builder builder = Option.builder()
      .longOpt(optName)
      .hasArg()
      .valueSeparator(',')
      .required(isRequired)
      .desc(description);

  if (unlimitedArgs) {
    builder.hasArgs();
  }

  return builder.build();
}
 
开发者ID:spotify,项目名称:spydra,代码行数:26,代码来源:CliHelper.java

示例7: parseCommandLine

import org.apache.commons.cli.Option; //导入依赖的package包/类
/**
 *  Usage:  ReplicaStatsRetriever  \
 *             -brokerstatszk    datazk001:2181/data07    \
 *             -brokerstatstopic brokerstats              \
 *             -clusterzk  m10nzk001:2181,...,m10nzk007:2181/m10n07 \
 *             -seconds 43200
 */
private static CommandLine parseCommandLine(String[] args) {
  Option config = new Option(CONFIG, true, "operator config");
  Option brokerStatsZookeeper =
      new Option(BROKERSTATS_ZOOKEEPER, true, "zookeeper for brokerstats topic");
  Option brokerStatsTopic = new Option(BROKERSTATS_TOPIC, true, "topic for brokerstats");
  Option clusterZookeeper = new Option(CLUSTER_ZOOKEEPER, true, "cluster zookeeper");
  Option seconds = new Option(SECONDS, true, "examined time window in seconds");
  options.addOption(config).addOption(brokerStatsZookeeper).addOption(brokerStatsTopic)
      .addOption(clusterZookeeper).addOption(seconds);

  if (args.length < 6) {
    printUsageAndExit();
  }

  CommandLineParser parser = new DefaultParser();
  CommandLine cmd = null;
  try {
    cmd = parser.parse(options, args);
  } catch (ParseException | NumberFormatException e) {
    printUsageAndExit();
  }
  return cmd;
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:31,代码来源:ReplicaStatsRetriever.java

示例8: parseCommandLine

import org.apache.commons.cli.Option; //导入依赖的package包/类
/**
 *  Usage:  BrokerStatsRetriever  \
 *             --brokerstatszk    datazk001:2181/data07    \
 *             --brokerstatstopic brokerstats              \
 *             --broker  kafkabroker001
 */
private static CommandLine parseCommandLine(String[] args) {
  Option config = new Option(CONFIG, true, "operator config");
  Option brokerStatsZookeeper =
      new Option(BROKERSTATS_ZOOKEEPER, true, "zookeeper for brokerstats topic");
  Option brokerStatsTopic = new Option(BROKERSTATS_TOPIC, true, "topic for brokerstats");
  Option broker = new Option(BROKERNAME, true, "broker name");
  options.addOption(config).addOption(brokerStatsZookeeper).addOption(brokerStatsTopic)
      .addOption(broker);

  if (args.length < 6) {
    printUsageAndExit();
  }

  CommandLineParser parser = new DefaultParser();
  CommandLine cmd = null;
  try {
    cmd = parser.parse(options, args);
  } catch (ParseException | NumberFormatException e) {
    printUsageAndExit();
  }
  return cmd;
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:29,代码来源:BrokerStatsFilter.java

示例9: parseCommandLine

import org.apache.commons.cli.Option; //导入依赖的package包/类
private static CommandLine parseCommandLine(String[] args) {

    Option host = new Option(BROKER_NAME, true, "kafka broker");
    Option jmxPort = new Option(JMX_PORT, true, "kafka jmx port number");
    jmxPort.setArgName("kafka jmx port number");

    Option metric = new Option(METRICS_NAME, true, "jmx metric name");

    options.addOption(jmxPort).addOption(host).addOption(metric);

    if (args.length < 4) {
      printUsageAndExit();
    }
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = null;
    try {
      cmd = parser.parse(options, args);
    } catch (ParseException | NumberFormatException e) {
      printUsageAndExit();
    }
    return cmd;
  }
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:23,代码来源:MetricsFetcher.java

示例10: commandLine2Properties

import org.apache.commons.cli.Option; //导入依赖的package包/类
public static Properties commandLine2Properties(final CommandLine commandLine) {
    Properties properties = new Properties();
    Option[] opts = commandLine.getOptions();

    if (opts != null) {
        for (Option opt : opts) {
            String name = opt.getLongOpt();
            String value = commandLine.getOptionValue(name);
            if (value != null) {
                properties.setProperty(name, value);
            }
        }
    }

    return properties;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:17,代码来源:ServerUtil.java

示例11: buildCommandlineOptions

import org.apache.commons.cli.Option; //导入依赖的package包/类
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("b", "brokerName", true, "broker name");
    opt.setRequired(true);
    options.addOption(opt);
    return options;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:8,代码来源:WipeWritePermSubCommand.java

示例12: createOptions

import org.apache.commons.cli.Option; //导入依赖的package包/类
/**
 * Create the CLI Options
 * 
 * @return the CLI Options
 * @throws IllegalArgumentException
 */
private static Options createOptions() throws IllegalArgumentException {
	Options options = new Options();

	// add an option
	options.addOption("help", false, "print this message");

	options.addOption("start", false, "start the SQL Web server");

	options.addOption("stop", false, "stop the SQL Web server");

	options.addOption("version", false, "print version");

	String propertiesOptionMesssage = getPropertiesOptionMessage();

	@SuppressWarnings("static-access")
	Option propertiesOption = OptionBuilder.withArgName("file").hasArg().withDescription(propertiesOptionMesssage)
			.create("properties");

	@SuppressWarnings("static-access")
	Option hostOption = OptionBuilder.withArgName("hostname").hasArg().withDescription("hostname of the Web server")
			.create("host");

	@SuppressWarnings("static-access")
	Option portOption = OptionBuilder.withArgName("port number").hasArg()
			.withDescription("port number of the Web server. Defaults to " + WebServerApi.DEFAULT_PORT)
			.create("port");

	options.addOption(propertiesOption);
	options.addOption(hostOption);
	options.addOption(portOption);

	return options;
}
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:40,代码来源:WebServer.java

示例13: constructPosixOptions

import org.apache.commons.cli.Option; //导入依赖的package包/类
/**
 * Construct and provide Posix-compatible Options.
 * 
 * @return Options expected from command-line of Posix form.
 */
private static Options constructPosixOptions() {
	final Options posixOptions = new Options();
	posixOptions.addOption(
			Option.builder(VERBOSE_OPTION).desc("Enable verbose mode").hasArg(false).required(false).build());
	posixOptions.addOption(
			Option.builder(PASSWORD_OPTION).desc("User defined password").hasArg(true).required(false).build());
	posixOptions.addOption(Option.builder(CIPHERED_FILE_OPTION)
			.desc("Input ciphered file (or directory) to decipher").hasArg(true).required(true).build());
	posixOptions.addOption(Option.builder(PLAIN_FILE_OPTION).desc("Output plain file (or directory)").hasArg(true)
			.required(true).build());
	posixOptions.addOption(
			Option.builder(RECURSIVE_OPTION).desc("Enable recursive mode (WARNING : MAY TAKE A LONG TIME !)")
					.hasArg(false).required(false).build());

	return posixOptions;
}
 
开发者ID:Mikiya83,项目名称:hbs_decipher,代码行数:22,代码来源:QNAPFileDecrypter.java

示例14: getCommandName

import org.apache.commons.cli.Option; //导入依赖的package包/类
private static String getCommandName(String[] args) throws ParseException {

        Options opts = new Options();
        asList(CMOptions.HELP, CMOptions.VERSION, CMOptions.HOST, CMOptions.USER, CMOptions.PASSWORD).stream().map(
           new Function<Option, Option>() {

              @Override
              public Option apply(Option o) {
                Option c = CMOptions.clone(o);
                c.setRequired(false);
                return c;
              }
          }).forEach(o -> opts.addOption(o));

          CommandLine parser = new DefaultParser().parse(opts, args, true);
          if(parser.getArgs().length == 0) {
              throw new CMCommandLineException(format("Canmnot extract command name from arguments: '%s'.",
                        getArgsLogString(args)));
          }
          String commandName = parser.getArgs()[0];
          logger.debug(format("Command name '%s' extracted from command line '%s'.", commandName, getArgsLogString(args)));
          return commandName;
    }
 
开发者ID:SAP,项目名称:devops-cm-client,代码行数:24,代码来源:Commands.java

示例15: printPrelude

import org.apache.commons.cli.Option; //导入依赖的package包/类
public void printPrelude(Option task) {
	String applicationName = Settings.getString(SettingCodes.APPLICATION_NAME, Bundle.SETTINGS, null);
	String applicationVersion = Settings.getString(SettingCodes.APPLICATION_VERSION, Bundle.SETTINGS, null);
	String instanceName = Settings.getInstanceName();
	if (!CommonUtil.isEmptyString(applicationName)) {
		println(applicationName);
	}
	if (!CommonUtil.isEmptyString(applicationVersion)) {
		println("version: " + applicationVersion);
	}
	if (!CommonUtil.isEmptyString(instanceName)) {
		println("instance: " + instanceName);
	}
	println("jvm: " + System.getProperty("java.version"));
	if (task != null && !CommonUtil.isEmptyString(task.getDescription())) {
		println(task.getDescription());
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:19,代码来源:JobOutput.java


注:本文中的org.apache.commons.cli.Option类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。