本文整理匯總了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;
}
示例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;
}
示例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));
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}
示例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;
}