當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。