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


Java OptionBuilder类代码示例

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


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

示例1: testCreateWithOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
/**
 * Test that options passed to the constructor are used.
 */
@SuppressWarnings("static-access")
public void testCreateWithOptions() throws Exception {
  // Create new option newOpt
  Option opt = OptionBuilder.withArgName("int")
  .hasArg()
  .withDescription("A new option")
  .create("newOpt");
  Options opts = new Options();
  opts.addOption(opt);

  // Check newOpt is actually used to parse the args
  String[] args = new String[2];
  args[0] = "--newOpt";
  args[1] = "7";
  GenericOptionsParser g = new GenericOptionsParser(opts, args);
  assertEquals("New option was ignored",
    "7", g.getCommandLine().getOptionValues("newOpt")[0]);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:22,代码来源:TestGenericOptionsParser.java

示例2: createOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的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

示例3: getExtraOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
/**
 * Create related options for SQL Server extra parameters.
 *
 * @return
 */
@SuppressWarnings("static-access")
private RelatedOptions getExtraOptions() {
  // Connection args (common)
  RelatedOptions extraOptions =
    new RelatedOptions("SQL Server extra options:");

  extraOptions.addOption(OptionBuilder.withArgName("string").hasArg()
    .withDescription("Optional schema name")
    .withLongOpt(SCHEMA).create());

  extraOptions.addOption(OptionBuilder.withArgName("string").hasArg()
    .withDescription("Optional table hints to use")
    .withLongOpt(TABLE_HINTS).create());

  extraOptions.addOption(OptionBuilder
    .withDescription("Allow identity inserts")
    .withLongOpt(IDENTITY_INSERT).create());

  return extraOptions;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:26,代码来源:SQLServerManager.java

示例4: getExtraOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
/** {@inheritDoc}. */
@Override
@SuppressWarnings("static-access")
protected RelatedOptions getExtraOptions() {
  RelatedOptions extraOptions = super.getExtraOptions();

  extraOptions.addOption(OptionBuilder.withArgName("string").hasArg()
    .withDescription("String to encode TRUE value")
    .withLongOpt(BOOLEAN_TRUE_STRING).create());

  extraOptions.addOption(OptionBuilder.withArgName("string").hasArg()
    .withDescription("String to encode FALSE value")
    .withLongOpt(BOOLEAN_FALSE_STRING).create());

  return extraOptions;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:17,代码来源:DirectPostgresqlManager.java

示例5: addValidationOpts

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
@SuppressWarnings("static-access")
protected void addValidationOpts(RelatedOptions validationOptions) {
  validationOptions.addOption(OptionBuilder
    .withDescription("Validate the copy using the configured validator")
    .withLongOpt(VALIDATE_ARG)
    .create());
  validationOptions.addOption(OptionBuilder
    .withArgName(VALIDATOR_CLASS_ARG).hasArg()
    .withDescription("Fully qualified class name for the Validator")
    .withLongOpt(VALIDATOR_CLASS_ARG)
    .create());
  validationOptions.addOption(OptionBuilder
    .withArgName(VALIDATION_THRESHOLD_CLASS_ARG).hasArg()
    .withDescription("Fully qualified class name for ValidationThreshold")
    .withLongOpt(VALIDATION_THRESHOLD_CLASS_ARG)
    .create());
  validationOptions.addOption(OptionBuilder
    .withArgName(VALIDATION_FAILURE_HANDLER_CLASS_ARG).hasArg()
    .withDescription("Fully qualified class name for "
      + "ValidationFailureHandler")
    .withLongOpt(VALIDATION_FAILURE_HANDLER_CLASS_ARG)
    .create());
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:24,代码来源:BaseSqoopTool.java

示例6: configureOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
@Override
public void configureOptions(ToolOptions toolOptions) {
  toolOptions.addUniqueOptions(getCommonOptions());
  toolOptions.addUniqueOptions(getImportOptions());
  toolOptions.addUniqueOptions(getOutputFormatOptions());
  toolOptions.addUniqueOptions(getInputFormatOptions());
  toolOptions.addUniqueOptions(getHiveOptions(true));
  toolOptions.addUniqueOptions(getHBaseOptions());
  toolOptions.addUniqueOptions(getHCatalogOptions());
  toolOptions.addUniqueOptions(getHCatImportOnlyOptions());
  toolOptions.addUniqueOptions(getAccumuloOptions());

  // get common codegen opts.
  RelatedOptions codeGenOpts = getCodeGenOpts(false);

  // add import-specific codegen opts:
  codeGenOpts.addOption(OptionBuilder.withArgName("file")
      .hasArg()
      .withDescription("Disable code generation; use specified jar")
      .withLongOpt(JAR_FILE_NAME_ARG)
      .create());

  toolOptions.addUniqueOptions(codeGenOpts);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:25,代码来源:MainframeImportTool.java

示例7: configureOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
@Override
/** Configure the command-line arguments we expect to receive */
public void configureOptions(ToolOptions toolOptions) {

  toolOptions.addUniqueOptions(getCommonOptions());

  RelatedOptions codeGenOpts = getCodeGenOpts(false);
  codeGenOpts.addOption(OptionBuilder.withArgName("table-name")
      .hasArg()
      .withDescription("Table to generate code for")
      .withLongOpt(TABLE_ARG)
      .create());
  codeGenOpts.addOption(OptionBuilder.withArgName("statement")
      .hasArg()
      .withDescription("SQL 'statement' to generate code for")
      .withLongOpt(SQL_QUERY_ARG)
      .create(SQL_QUERY_SHORT_ARG));
  toolOptions.addUniqueOptions(codeGenOpts);

  toolOptions.addUniqueOptions(getOutputFormatOptions());
  toolOptions.addUniqueOptions(getInputFormatOptions());
  toolOptions.addUniqueOptions(getHiveOptions(true));
  toolOptions.addUniqueOptions(getHCatalogOptions());
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:25,代码来源:CodeGenTool.java

示例8: getIncrementalOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
/**
 * Return options for incremental import.
 */
protected RelatedOptions getIncrementalOptions() {
  RelatedOptions incrementalOpts =
      new RelatedOptions("Incremental import arguments");

  incrementalOpts.addOption(OptionBuilder.withArgName("import-type")
      .hasArg()
      .withDescription(
      "Define an incremental import of type 'append' or 'lastmodified'")
      .withLongOpt(INCREMENT_TYPE_ARG)
      .create());
  incrementalOpts.addOption(OptionBuilder.withArgName("column")
      .hasArg()
      .withDescription("Source column to check for incremental change")
      .withLongOpt(INCREMENT_COL_ARG)
      .create());
  incrementalOpts.addOption(OptionBuilder.withArgName("value")
      .hasArg()
      .withDescription("Last imported value in the incremental check column")
      .withLongOpt(INCREMENT_LAST_VAL_ARG)
      .create());

  return incrementalOpts;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:27,代码来源:ImportTool.java

示例9: configureOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
@Override
/** Configure the command-line arguments we expect to receive */
public void configureOptions(ToolOptions toolOptions) {

  toolOptions.addUniqueOptions(getCommonOptions());

  RelatedOptions hiveOpts = getHiveOptions(false);
  hiveOpts.addOption(OptionBuilder.withArgName("table-name")
      .hasArg()
      .withDescription("The db table to read the definition from")
      .withLongOpt(TABLE_ARG)
      .create());
  toolOptions.addUniqueOptions(hiveOpts);

  toolOptions.addUniqueOptions(getOutputFormatOptions());
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:17,代码来源:CreateHiveTableTool.java

示例10: buildOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
/**
 * Build command-line options and descriptions
 *
 * @return command line options
 */
public static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no 
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("outputFilename");
  options.addOption(OptionBuilder.create("o"));
  
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFilename");
  options.addOption(OptionBuilder.create("i"));
  
  options.addOption("p", "processor", true, "");
  options.addOption("v", "verbose", false, "");
  options.addOption("f", "fix-txids", false, "");
  options.addOption("r", "recover", false, "");
  options.addOption("h", "help", false, "");

  return options;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:OfflineEditsViewer.java

示例11: buildOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
/**
 * Build command-line options and descriptions
 */
public static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no 
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("outputFile");
  options.addOption(OptionBuilder.create("o"));
  
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFile");
  options.addOption(OptionBuilder.create("i"));
  
  options.addOption("p", "processor", true, "");
  options.addOption("h", "help", false, "");
  options.addOption("skipBlocks", false, "");
  options.addOption("printToScreen", false, "");
  options.addOption("delimiter", true, "");

  return options;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:OfflineImageViewer.java

示例12: buildOptions

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
/**
 * Build command-line options and descriptions
 */
private static Options buildOptions() {
  Options options = new Options();

  // Build in/output file arguments, which are required, but there is no
  // addOption method that can specify this
  OptionBuilder.isRequired();
  OptionBuilder.hasArgs();
  OptionBuilder.withLongOpt("inputFile");
  options.addOption(OptionBuilder.create("i"));

  options.addOption("o", "outputFile", true, "");
  options.addOption("p", "processor", true, "");
  options.addOption("h", "help", false, "");
  options.addOption("maxSize", true, "");
  options.addOption("step", true, "");
  options.addOption("addr", true, "");
  options.addOption("delimiter", true, "");
  options.addOption("t", "temp", true, "");

  return options;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:OfflineImageViewerPB.java

示例13: ListServices

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
/**
 * 
 */
public ListServices(String[] args) {
	Options opts = new Options();
	opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?"));
	opts.addOption(OptionBuilder.withLongOpt("host").withArgName("hostname").hasArg().withDescription("specifies the hostname on which the rmi registry listens (default: localhost)").create("h"));
	opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg().withDescription(String.format("specifies the port on which rmi registry listens (default: %d)", Registry.REGISTRY_PORT)).create("p"));
			
	try {
		CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
		if (cmd.hasOption("help")) 
			CliUtils.print_usage_quit(StartLM.class.getSimpleName(), opts, null, 0);
		_port = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT)));
		_host = cmd.getOptionValue("host", "localhost");
	} catch (Exception e) {
		LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage());
		CliUtils.print_usage_quit(StartLM.class.getSimpleName(), opts, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
	}	
}
 
开发者ID:tudarmstadt-lt,项目名称:topicrawler,代码行数:21,代码来源:ListServices.java

示例14: StartRMI

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
@SuppressWarnings("static-access")
public StartRMI(String[] args) {
	LOG.warn("This main is only for convencience and might be deprectated soon. Consider using {}.", StartLM.class.getName());
	Options opts = new Options();
	opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?"));
	opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg().withDescription(String.format("specifies the port on which rmi registry listens (default: %d)", Registry.REGISTRY_PORT)).create("p"));
	
	
	try {
		CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
		if (cmd.hasOption("help")) 
			CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0);
		_port = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT)));
		
	} catch (Exception e) {
		LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage());
		CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
	}
}
 
开发者ID:tudarmstadt-lt,项目名称:topicrawler,代码行数:20,代码来源:StartRMI.java

示例15: main

import org.apache.commons.cli.OptionBuilder; //导入依赖的package包/类
@SuppressWarnings("static-access")
public static void main(String[] args) {
	Options opts = new Options();
	opts.addOption(new Option("?", "help", false, "display this message"));
	opts.addOption(OptionBuilder.withLongOpt("host").withArgName("hostname").hasArgs(1).withDescription("specifies the hostname (default: localhost)").create("h"));
	opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg().withDescription("specifies the port (default: 0, which means a random port)").create("p"));
	opts.addOption(OptionBuilder.withLongOpt("dir").withArgName("directory").isRequired().hasArg().withDescription("specify the directory that contains '.txt' files that are used as source for this language model").create("d"));
	opts.addOption(OptionBuilder.withLongOpt("parallel").withArgName("num-threads").hasArg().withDescription("specify number of parallel threads").create());
	opts.addOption(OptionBuilder.withLongOpt("").hasArg().create());
	
	try {
		CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
		if (cmd.hasOption("help")) 
			CliUtils.print_usage(System.err, CliTest.class.getSimpleName(), opts, USAGE_HEADER, null);

		Map<String, String> map = CliUtils.getOptionsMap(cmd.getOptions());
		
		System.out.println(map);

	} catch (Exception e) {
		LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage());
		CliUtils.print_usage(System.err, CliTest.class.getSimpleName(), opts, USAGE_HEADER, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()));
	}


}
 
开发者ID:tudarmstadt-lt,项目名称:topicrawler,代码行数:27,代码来源:CliTest.java


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