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


Java OptionBuilder.hasArg方法代码示例

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


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

示例1: AddFind

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
public AddFind() {
	super("add", "a");

	OptionBuilder.withArgName("outputDir");
	OptionBuilder.withLongOpt("output");
	OptionBuilder.hasArg();
	OptionBuilder.withDescription("override default download directory");
	OptionBuilder.withType(File.class);
	getOptions().addOption(OptionBuilder.create('o'));
	getOptions().addOption("r", "recurse", false,
			"recurse sub-directories.");
	getOptions().addOption("f", "find", false,
			"only find files, don't add.");
	getOptions().addOption("h", "help", false,
			"display help about this command");
	getOptions()
			.addOption("l", "list", false, "list previous find results");
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:19,代码来源:AddFind.java

示例2: AddFind

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
public AddFind()
{
	super("add", "a");

	OptionBuilder.withArgName("outputDir");
	OptionBuilder.withLongOpt("output");
	OptionBuilder.hasArg();
	OptionBuilder.withDescription("override default download directory");
	OptionBuilder.withType(File.class);
	getOptions().addOption( OptionBuilder.create('o') );
	getOptions().addOption("r", "recurse", false, "recurse sub-directories.");
	getOptions().addOption("f", "find", false, "only find files, don't add.");
	getOptions().addOption("h", "help", false, "display help about this command");
	getOptions().addOption("l", "list", false, "list previous find results");
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:16,代码来源:AddFind.java

示例3: initArgOption

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
private static void initArgOption(boolean required, String optionName, String optionArg) {
	OptionBuilder.withArgName(optionName);
	OptionBuilder.isRequired(required);
	OptionBuilder.hasArg();
	Option opt = OptionBuilder.create(optionArg);
	OPTIONS.addOption(opt);
}
 
开发者ID:boly38,项目名称:mongodbdump-java-wrapper,代码行数:8,代码来源:Main.java

示例4: createCommandLineOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Creates the command line structure / options.
 *
 * @return the command line {@link Options}
 */
private static Options createCommandLineOptions() {
  Options options = new Options();
  
  OptionBuilder.withLongOpt("keyword-properties");
  OptionBuilder.withDescription("Location of the keyword-optimizer.properties file.");
  OptionBuilder.hasArg(true);
  OptionBuilder.withArgName("file");
  options.addOption(OptionBuilder.create("kp"));

  OptionBuilder.withLongOpt("ads-properties");
  OptionBuilder.withDescription("Location of the ads.properties file.");
  OptionBuilder.hasArg(true);
  OptionBuilder.withArgName("file");
  options.addOption(OptionBuilder.create("ap"));

  OptionBuilder.withLongOpt("port");
  OptionBuilder.withDescription("Port for the REST HTTP server.");
  OptionBuilder.hasArg(true);
  OptionBuilder.withArgName("port");
  options.addOption(OptionBuilder.create("p"));
  
  OptionBuilder.withLongOpt("context-path");
  OptionBuilder.withDescription("Context path for the REST HTTP server.");
  OptionBuilder.hasArg(true);
  OptionBuilder.withArgName("path");
  options.addOption(OptionBuilder.create("cp"));
  
  return options;
}
 
开发者ID:googleads,项目名称:keyword-optimizer,代码行数:35,代码来源:ApiServer.java

示例5: run

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the LinkRank tool.
 */
public int run(String[] args) throws Exception {

  Options options = new Options();
  OptionBuilder.withArgName("help");
  OptionBuilder.withDescription("show this help message");
  Option helpOpts = OptionBuilder.create("help");
  options.addOption(helpOpts);

  OptionBuilder.withArgName("webgraphdb");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the web graph db to use");
  Option webgraphOpts = OptionBuilder.create("webgraphdb");
  options.addOption(webgraphOpts);

  CommandLineParser parser = new GnuParser();
  try {

    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("LinkRank", options);
      return -1;
    }

    String webGraphDb = line.getOptionValue("webgraphdb");

    analyze(new Path(webGraphDb));
    return 0;
  } catch (Exception e) {
    LOG.error("LinkAnalysis: " + StringUtils.stringifyException(e));
    return -2;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:37,代码来源:LinkRank.java

示例6: run

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the LinkDumper tool. This simply creates the database, to read the
 * values the nested Reader tool must be used.
 */
public int run(String[] args) throws Exception {

  Options options = new Options();
  OptionBuilder.withArgName("help");
  OptionBuilder.withDescription("show this help message");
  Option helpOpts = OptionBuilder.create("help");
  options.addOption(helpOpts);

  OptionBuilder.withArgName("webgraphdb");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the web graph database to use");
  Option webGraphDbOpts = OptionBuilder.create("webgraphdb");
  options.addOption(webGraphDbOpts);

  CommandLineParser parser = new GnuParser();
  try {

    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("LinkDumper", options);
      return -1;
    }

    String webGraphDb = line.getOptionValue("webgraphdb");
    dumpLinks(new Path(webGraphDb));
    return 0;
  } catch (Exception e) {
    LOG.error("LinkDumper: " + StringUtils.stringifyException(e));
    return -2;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:37,代码来源:LinkDumper.java

示例7: createCommandLineOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Creates the command line options.
 *
 * @return the {@link Options}
 */
private static Options createCommandLineOptions() {
  Options options = new Options();

  OptionBuilder.withArgName("help");
  OptionBuilder.hasArg(false);
  OptionBuilder.withDescription("print this message");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("help"));

  OptionBuilder.withArgName("file");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription("aw-report-alerting-sample.properties file.");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("file"));

  OptionBuilder.withArgName("accountIdsFile");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription(
      "Consider ONLY the account IDs specified on the file to run the report");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("accountIdsFile"));

  OptionBuilder.withArgName("debug");
  OptionBuilder.hasArg(false);
  OptionBuilder.withDescription("Will display all the debug information. "
      + "If the option 'verbose' is activated, "
      + "all the information will be displayed on the console as well");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("debug"));

  return options;
}
 
开发者ID:googleads,项目名称:adwords-alerting,代码行数:38,代码来源:AwAlerting.java

示例8: buildOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Method for building the allowed options.
 * @param options Options object for adding the options created with OptionBuilder.
 */
private void buildOptions(Options options){        
    OptionBuilder.withArgName(OPTION_HELP);
    OptionBuilder.withLongOpt(OPTION_HELP);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Print help message and exit.");
    options.addOption(OptionBuilder.create('h'));
    
    OptionBuilder.withArgName(OPTION_INPUT_JSON);
    OptionBuilder.withLongOpt(OPTION_INPUT_JSON);
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Specify the JSON input file.");
    options.addOption(OptionBuilder.create("j"));
}
 
开发者ID:openmainframeproject,项目名称:ade,代码行数:19,代码来源:UpdateGroups.java

示例9: addPlatformSpecificOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
@Override
public void addPlatformSpecificOptions(Options options){
    OptionBuilder.withArgName(OPTION_YEAR);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("year of messages in Linux syslogs");
    options.addOption(OptionBuilder.create(OPTION_YEAR));
}
 
开发者ID:openmainframeproject,项目名称:ade,代码行数:8,代码来源:LinuxOptions.java

示例10: parseArgs

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Method to parse specific arguments for "Analyze".
 */
@Override
protected final void parseArgs(String[] args) throws AdeException {
    final Options options = new Options();

    OptionBuilder.withArgName(OPTION_SOURCES);
    OptionBuilder.withLongOpt(OPTION_SOURCES);
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Specify the Source to be analyzed.  ");
    options.addOption(OptionBuilder.create("s"));

    super.parseArgs(options, args);

}
 
开发者ID:openmainframeproject,项目名称:ade,代码行数:18,代码来源:Analyze.java

示例11: parseArgs

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * parse args
 */
private static CommandLine parseArgs(Options opts, String... args)
throws IllegalArgumentException {

  OptionBuilder.withArgName("NameNode|DataNode");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("specify jmx service (NameNode by default)");
  Option jmx_service = OptionBuilder.create("service");

  OptionBuilder.withArgName("mbean server");
  OptionBuilder.hasArg();
  OptionBuilder
  .withDescription("specify mbean server (localhost by default)");
  Option jmx_server = OptionBuilder.create("server");

  OptionBuilder.withDescription("print help");
  Option jmx_help = OptionBuilder.create("help");

  OptionBuilder.withArgName("mbean server port");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("specify mbean server port, "
      + "if missing - it will try to connect to MBean Server in the same VM");
  Option jmx_port = OptionBuilder.create("port");

  OptionBuilder.withArgName("VM's connector url");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("connect to the VM on the same machine;"
      + "\n use:\n jstat -J-Djstat.showUnsupported=true -snap <vmpid> | "
      + "grep sun.management.JMXConnectorServer.address\n "
      + "to find the url");
  Option jmx_localVM = OptionBuilder.create("localVM");

  opts.addOption(jmx_server);
  opts.addOption(jmx_help);
  opts.addOption(jmx_service);
  opts.addOption(jmx_port);
  opts.addOption(jmx_localVM);

  CommandLine commandLine = null;
  CommandLineParser parser = new GnuParser();
  try {
    commandLine = parser.parse(opts, args, true);
  } catch (ParseException e) {
    printUsage(opts);
    throw new IllegalArgumentException("invalid args: " + e.getMessage());
  }
  return commandLine;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:51,代码来源:JMXGet.java

示例12: main

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the resolve urls tool.
 */
public static void main(String[] args) {

  Options options = new Options();
  OptionBuilder.withArgName("help");
  OptionBuilder.withDescription("show this help message");
  Option helpOpts = OptionBuilder.create("help");
  options.addOption(helpOpts);

  OptionBuilder.withArgName("urls");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the urls file to check");
  Option urlOpts = OptionBuilder.create("urls");
  options.addOption(urlOpts);

  OptionBuilder.withArgName("numThreads");
  OptionBuilder.hasArgs();
  OptionBuilder.withDescription("the number of threads to use");
  Option numThreadOpts = OptionBuilder.create("numThreads");
  options.addOption(numThreadOpts);

  CommandLineParser parser = new GnuParser();
  try {
    // parse out common line arguments
    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("urls")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("ResolveUrls", options);
      return;
    }

    // get the urls and the number of threads and start the resolver
    String urls = line.getOptionValue("urls");
    int numThreads = 100;
    String numThreadsStr = line.getOptionValue("numThreads");
    if (numThreadsStr != null) {
      numThreads = Integer.parseInt(numThreadsStr);
    }
    ResolveUrls resolve = new ResolveUrls(urls, numThreads);
    resolve.resolveUrls();
  } catch (Exception e) {
    LOG.error("ResolveUrls: " + StringUtils.stringifyException(e));
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:47,代码来源:ResolveUrls.java

示例13: run

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the ScoreUpdater tool.
 */
public int run(String[] args) throws Exception {

  Options options = new Options();
  OptionBuilder.withArgName("help");
  OptionBuilder.withDescription("show this help message");
  Option helpOpts = OptionBuilder.create("help");
  options.addOption(helpOpts);

  OptionBuilder.withArgName("crawldb");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the crawldb to use");
  Option crawlDbOpts = OptionBuilder.create("crawldb");
  options.addOption(crawlDbOpts);

  OptionBuilder.withArgName("webgraphdb");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the webgraphdb to use");
  Option webGraphOpts = OptionBuilder.create("webgraphdb");
  options.addOption(webGraphOpts);

  CommandLineParser parser = new GnuParser();
  try {

    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb")
        || !line.hasOption("crawldb")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("ScoreUpdater", options);
      return -1;
    }

    String crawlDb = line.getOptionValue("crawldb");
    String webGraphDb = line.getOptionValue("webgraphdb");
    update(new Path(crawlDb), new Path(webGraphDb));
    return 0;
  } catch (Exception e) {
    LOG.error("ScoreUpdater: " + StringUtils.stringifyException(e));
    return -1;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:44,代码来源:ScoreUpdater.java

示例14: main

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
/**
 * Runs the NodeReader tool. The command line arguments must contain a
 * webgraphdb path and a url. The url must match the normalized url that is
 * contained in the NodeDb of the WebGraph.
 */
public static void main(String[] args) throws Exception {

  Options options = new Options();
  OptionBuilder.withArgName("help");
  OptionBuilder.withDescription("show this help message");
  Option helpOpts = OptionBuilder.create("help");
  options.addOption(helpOpts);

  OptionBuilder.withArgName("webgraphdb");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("the webgraphdb to use");
  Option webGraphOpts = OptionBuilder.create("webgraphdb");
  options.addOption(webGraphOpts);

  OptionBuilder.withArgName("url");
  OptionBuilder.hasOptionalArg();
  OptionBuilder.withDescription("the url to dump");
  Option urlOpts = OptionBuilder.create("url");
  options.addOption(urlOpts);

  CommandLineParser parser = new GnuParser();
  try {

    // command line must take a webgraphdb and a url
    CommandLine line = parser.parse(options, args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb")
        || !line.hasOption("url")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("WebGraphReader", options);
      return;
    }

    // dump the values to system out and return
    String webGraphDb = line.getOptionValue("webgraphdb");
    String url = line.getOptionValue("url");
    NodeReader reader = new NodeReader(NutchConfiguration.create());
    reader.dumpUrl(new Path(webGraphDb), url);

    return;
  } catch (Exception e) {
    e.printStackTrace();
    return;
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:50,代码来源:NodeReader.java

示例15: buildOptions

import org.apache.commons.cli.OptionBuilder; //导入方法依赖的package包/类
public static Options buildOptions(Options subClassOptions) {
    /* Add the options from subClass */
    Options options = new Options();
    for (Object subClassOption : subClassOptions.getOptions()) {
        Option option = (Option) subClassOption;
        options.addOption(option);
    }

    /* Add the general options */
    OptionBuilder.withArgName(OPTION_HELP);
    OptionBuilder.withLongOpt(OPTION_HELP);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Print help message and exit");
    options.addOption(OptionBuilder.create('h'));

    OptionBuilder.withArgName(OPTION_INPUT_FILE);
    OptionBuilder.withLongOpt(OPTION_INPUT_FILE);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Input file name or 'stdin'");
    options.addOption(OptionBuilder.create('f'));

    OptionBuilder.withArgName(OPTION_INPUT_DIR);
    OptionBuilder.withLongOpt(OPTION_INPUT_DIR);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Input dir name");
    options.addOption(OptionBuilder.create('d'));

    OptionBuilder.withArgName(OPTION_SOURCES);
    OptionBuilder.withLongOpt(OPTION_SOURCES);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Source Names.");
    options.addOption(OptionBuilder.create('s'));

    OptionBuilder.withArgName(OPTION_OS_TYPE);
    OptionBuilder.withLongOpt(OPTION_OS_TYPE);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("The OS Type."
            + "If this option is omitted, the default is Linux");
    options.addOption(OptionBuilder.create('o'));

    OptionBuilder.withArgName(OPTION_GMT_OFFSET);
    OptionBuilder.withLongOpt(OPTION_GMT_OFFSET);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("hours offset from GMT");
    options.addOption(OptionBuilder.create('g'));

    return options;
}
 
开发者ID:openmainframeproject,项目名称:ade,代码行数:54,代码来源:AdeExtOptions.java


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