當前位置: 首頁>>代碼示例>>Java>>正文


Java PosixParser.parse方法代碼示例

本文整理匯總了Java中org.apache.commons.cli.PosixParser.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java PosixParser.parse方法的具體用法?Java PosixParser.parse怎麽用?Java PosixParser.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.cli.PosixParser的用法示例。


在下文中一共展示了PosixParser.parse方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import org.apache.commons.cli.PosixParser; //導入方法依賴的package包/類
/**
 * Parses the command line options
 * 
 * @return false if need to print help output
 * 
 * @throws Exception
 *           when parsing fails
 */
ParsedOutput parse() throws Exception {
  if (parsed == null) {
    PosixParser parser = new PosixParser();
    CommandLine popts = parser.parse(getOptionList(), argumentList, true);
    if (popts.hasOption(ConfigOption.HELP.getOpt())) {
      parsed = new ParsedOutput(null, this, true);
    } else {
      parsed = new ParsedOutput(popts, this, false);
    }
  }
  return parsed;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:ArgumentParser.java

示例2: getCommandLine

import org.apache.commons.cli.PosixParser; //導入方法依賴的package包/類
public static CommandLine getCommandLine( Options options, String[] args )
		throws ParseException {

	PosixParser parser = new PosixParser();
	CommandLine cmd = parser.parse( options, args );
	return cmd;
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:8,代碼來源:CLI.java

示例3: testOrder

import org.apache.commons.cli.PosixParser; //導入方法依賴的package包/類
@Test
public void testOrder() throws ParseException {
    Option optionA = new Option("a", "first");
    Options opts = new Options();
    opts.addOption(optionA);
    PosixParser posixParser = new PosixParser();
    CommandLine line = posixParser.parse(opts, null);
    assertFalse(line.hasOption(null));
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:10,代碼來源:BugCLI133Test.java

示例4: buildCommandline

import org.apache.commons.cli.PosixParser; //導入方法依賴的package包/類
public static CommandLine buildCommandline(String[] args) {
    final Options options = new Options();
    Option opt = new Option("h", "help", false, "Print help");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("g", "consumerGroup", true, "Consumer Group Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("t", "topic", true, "Topic Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("s", "subscription", true, "subscription");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("f", "returnFailedHalf", true, "return failed result, for half message");
    opt.setRequired(true);
    options.addOption(opt);

    PosixParser parser = new PosixParser();
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
        if (commandLine.hasOption('h')) {
            hf.printHelp("producer", options, true);
            return null;
        }
    } catch (ParseException e) {
        hf.printHelp("producer", options, true);
        return null;
    }

    return commandLine;
}
 
開發者ID:apache,項目名稱:rocketmq,代碼行數:40,代碼來源:Consumer.java

示例5: processOptions

import org.apache.commons.cli.PosixParser; //導入方法依賴的package包/類
private static void processOptions(String[] args)
{
   Options options = new Options();

   Option opt = new Option("in", true,
            "Input file oe-supported Use .sdf to specify the file type.");
   opt.setRequired(true);
   options.addOption(opt);

   opt = new Option("out", true,
            "Output file oe-supported Use .sdf to specify the file type.");
   opt.setRequired(true);
   options.addOption(opt);

   opt = new Option("bin", true,
            "bin definition. Use format \"bin_1_upperbound=bin_1_name|bin_2_upperbound=bin_2_name|bin_3_upperbound_=bin_3_name\"");
   opt.setRequired(true);
   options.addOption(opt);

   opt = new Option("dataTag", true,
            "SD tag containing data for binning");
   opt.setRequired(true);
   options.addOption(opt);

   opt = new Option("binTag", true,
            "SD tag used for storing bin names");
   opt.setRequired(true);
   options.addOption(opt);

   opt = new Option("ignoreModifier", false,
            "ignore leading '><= ~'");
   options.addOption(opt);

   opt = new Option("h", false,
            "print usage statement");
   opt.setRequired(false);
   options.addOption(opt);


   PosixParser parser = new PosixParser();
   CommandLine cl=null;

   try {
      cl = parser.parse(options, args);
   } catch (Exception exp) {
      // catch (ParseException exp) {
      System.err.println(exp.getMessage());
      exitWithHelp(options);
   }
   inFile = cl.getOptionValue("in");
   outFile = cl.getOptionValue("out");
   ignoreModifier = cl.hasOption("ignoreModifier");
   String binDefinition=cl.getOptionValue("bin");
   parseBins(binDefinition);

   binTag=cl.getOptionValue("binTag");
   dataTag=cl.getOptionValue("dataTag");
}
 
開發者ID:chemalot,項目名稱:chemalot,代碼行數:59,代碼來源:SDFBinning.java

示例6: buildCommandline

import org.apache.commons.cli.PosixParser; //導入方法依賴的package包/類
public static CommandLine buildCommandline(String[] args) {
    final Options options = new Options();
    // ////////////////////////////////////////////////////
    Option opt = new Option("h", "help", false, "Print help");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("g", "consumerGroup", true, "Consumer Group Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("t", "topic", true, "Topic Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("s", "subscription", true, "subscription");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("f", "returnFailedHalf", true, "return failed result, for half message");
    opt.setRequired(true);
    options.addOption(opt);

    // ////////////////////////////////////////////////////

    PosixParser parser = new PosixParser();
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
        if (commandLine.hasOption('h')) {
            hf.printHelp("producer", options, true);
            return null;
        }
    }
    catch (ParseException e) {
        hf.printHelp("producer", options, true);
        return null;
    }

    return commandLine;
}
 
開發者ID:medusar,項目名稱:rocketmq-commet,代碼行數:44,代碼來源:Consumer.java

示例7: buildCommandline

import org.apache.commons.cli.PosixParser; //導入方法依賴的package包/類
public static CommandLine buildCommandline(String[] args) {
    final Options options = new Options();
    // ////////////////////////////////////////////////////
    Option opt = new Option("h", "help", false, "Print help");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("g", "producerGroup", true, "Producer Group Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("t", "topic", true, "Topic Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("a", "tags", true, "Tags Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("k", "keys", true, "Keys Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("c", "msgCount", true, "Message Count");
    opt.setRequired(true);
    options.addOption(opt);

    // ////////////////////////////////////////////////////

    PosixParser parser = new PosixParser();
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
        if (commandLine.hasOption('h')) {
            hf.printHelp("producer", options, true);
            return null;
        }
    }
    catch (ParseException e) {
        hf.printHelp("producer", options, true);
        return null;
    }

    return commandLine;
}
 
開發者ID:medusar,項目名稱:rocketmq-commet,代碼行數:48,代碼來源:Producer.java

示例8: buildCommandline

import org.apache.commons.cli.PosixParser; //導入方法依賴的package包/類
public static CommandLine buildCommandline(String[] args) {
    final Options options = new Options();
    Option opt = new Option("h", "help", false, "Print help");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("g", "producerGroup", true, "Producer Group Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("t", "topic", true, "Topic Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("a", "tags", true, "Tags Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("k", "keys", true, "Keys Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("c", "msgCount", true, "Message Count");
    opt.setRequired(true);
    options.addOption(opt);

    PosixParser parser = new PosixParser();
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
        if (commandLine.hasOption('h')) {
            hf.printHelp("producer", options, true);
            return null;
        }
    } catch (ParseException e) {
        hf.printHelp("producer", options, true);
        return null;
    }

    return commandLine;
}
 
開發者ID:apache,項目名稱:rocketmq,代碼行數:44,代碼來源:Producer.java


注:本文中的org.apache.commons.cli.PosixParser.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。