本文整理匯總了Java中org.apache.commons.cli.OptionGroup類的典型用法代碼示例。如果您正苦於以下問題:Java OptionGroup類的具體用法?Java OptionGroup怎麽用?Java OptionGroup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OptionGroup類屬於org.apache.commons.cli包,在下文中一共展示了OptionGroup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkRequiredOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
public static void checkRequiredOptions() throws MissingOptionException {
OptionGroup[] groups = {contentGroup};
for(OptionGroup group : groups) {
ArrayList<Option> groupOptions = new ArrayList<Option>(group.getOptions());
boolean groupIsGiven = false;
for (Option option : groupOptions){
if (commandLine.hasOption(option.getOpt())) {
groupIsGiven = true;
break;
}
}
if (!groupIsGiven){
throw new MissingOptionException(groupOptions);
}
}
}
示例2: MixtureOptionPack
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
public MixtureOptionPack() {
super();
alg = new OptionGroup();
alg.addOption(reuse = new Option("Reuse","Use the reuse algorithm"))
.addOption(neal8 = new Option("Neal8","Use Neal's algorithm 8"))
.addOption(slice = new Option("Slice","Use the slice algorithm"));
alg.setRequired(true);
marg = new OptionGroup();
marg.addOption(marginalized = new Option("Marginalized","Marginalize out cluster parameters"))
.addOption(sampled = new Option("Sampled","Sample cluster parameters"));
marg.setRequired(true);
addOptionGroup(alg);
addOptionGroup(marg);
addOption("NumEmptyClusters", true, "Number of empty clusters to maintain (reuse,neal8)");
//options.addOption("MaxEmptyClusters", true, "Maximum number of empty clusters to introduce (slice)");
}
示例3: getOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的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;
}
示例4: init
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
private void init() {
options.addOption("v", "verbose", false,
"Verbose output; emits file and meta data delimiters");
options.addOption("p", "printkv", false, "Print key/value pairs");
options.addOption("e", "printkey", false, "Print keys");
options.addOption("m", "printmeta", false, "Print meta data of file");
options.addOption("b", "printblocks", false, "Print block index meta data");
options.addOption("h", "printblockheaders", false, "Print block headers for each block.");
options.addOption("k", "checkrow", false,
"Enable row order check; looks for out-of-order keys");
options.addOption("a", "checkfamily", false, "Enable family check");
options.addOption("w", "seekToRow", true,
"Seek to this row and print all the kvs for this row only");
options.addOption("s", "stats", false, "Print statistics");
OptionGroup files = new OptionGroup();
files.addOption(new Option("f", "file", true,
"File to scan. Pass full-path; e.g. hdfs://a:9000/hbase/hbase:meta/12/34"));
files.addOption(new Option("r", "region", true,
"Region to scan. Pass region name; e.g. 'hbase:meta,,1'"));
options.addOptionGroup(files);
}
示例5: getCommandLineOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
private static Options getCommandLineOptions() {
// create the Options
final Options options = new Options();
final OptionGroup startup = new OptionGroup();
final Option port = Option.builder("p")
.longOpt("port")
.desc("the port that the server will listen on.")
.type(Integer.class)
.numberOfArgs(1)
.build();
startup.addOption(port);
options.addOptionGroup(startup);
options.addOption("h", "help", false, "print these usage instructions and exit.");
options.addOption("?", "help", false, "print these usage instructions and exit.");
options.addOption("v", "version", false, "print product version and exit.");
return options;
}
示例6: appendOptionGroup
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
/**
* Appends the usage clause for an OptionGroup to a StringBuilder. The clause
* is wrapped in square brackets if the group is not required. The display of
* the options is handled by appendOption
*
* @param buff
* the StringBuilder to append to
* @param group
* the group to append
* @see #appendOption(StringBuffer,Option,boolean)
*/
protected void appendOptionGroup(final StringBuilder buff,
final OptionGroup group) {
if (!group.isRequired()) {
buff.append('[');
}
ArrayList<Object> optList = new ArrayList<Object>(group.getOptions());
Collections.sort(optList, getOptionComparator());
// for each option in the OptionGroup
for (Iterator<?> i = optList.iterator(); i.hasNext();) {
// whether the option is required or not is handled at group level
appendOption(buff, (Option)i.next(), true);
if (i.hasNext()) {
buff.append(" | ");
}
}
if (!group.isRequired()) {
buff.append(']');
}
}
示例7: createCLIOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
/**
* Creates the options needed by command line interface
*
* @return the options this CLI can handle
*/
public static Options createCLIOptions() {
options = new Options();
typeGroup = new OptionGroup();
Option msgTypeOpt = new Option("t", "message_type", true, "message type");
typeGroup.addOption(msgTypeOpt);
options.addOptionGroup(typeGroup);
options.addOption("h", "help", false, "show help.");
options.addOption("r", "response_file", true, "file to store the response in, optional");
options.addOption("d", "debug", false, "enable debug traces");
options.addOption("mp", "messaging_protocol", true,
"name of messaging protocol to be used, e.g. eiffel3, semantics");
contentGroup = new OptionGroup();
contentGroup.addOption(new Option("f", "content_file", true, "message content file"));
contentGroup.addOption(new Option("json", "json_content", true, "json content"));
options.addOptionGroup(contentGroup);
options.addOption("v", "list_versions", false, "lists the versions of generate and all loaded protocols");
return options;
}
示例8: checkRequiredOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
public static void checkRequiredOptions() throws MissingOptionException {
OptionGroup[] groups = {typeGroup, contentGroup};
for(OptionGroup group : groups) {
ArrayList<Option> groupOptions = new ArrayList<Option>(group.getOptions());
boolean groupIsGiven = false;
for (Option option : groupOptions){
if (commandLine.hasOption(option.getOpt())) {
groupIsGiven = true;
break;
}
}
if (!groupIsGiven){
throw new MissingOptionException(groupOptions);
}
}
}
示例9: getOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
private static Options getOptions() {
Options options = new Options();
options.addOption("b", "bind", true,
"Address to bind the Thrift server to. Not supported by the Nonblocking and HsHa server [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("h", "help", false, "Print help information");
options.addOption(null, "infoport", true, "Port for web UI");
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;
}
示例10: parseDefaultCommandLineArguments
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
/**
* Populates the default command line arguments that are common to all analyses.
*
* @param options The command line options object that should be modified.
*/
private void parseDefaultCommandLineArguments(Options options) {
OptionGroup modelGroup = new OptionGroup();
modelGroup.addOption(Option.builder("model").desc("Path to the model directory.").hasArg()
.argName("model directory").build());
modelGroup.addOption(Option.builder("cmodel").desc("Path to the compiled model.").hasArg()
.argName("compiled model").build());
modelGroup.setRequired(false);
options.addOptionGroup(modelGroup);
options.addOption(Option.builder("cp").desc("The classpath for the analysis.").hasArg()
.argName("classpath").required().longOpt("classpath").build());
options.addOption(Option.builder("in").desc("The input code for the analysis.").hasArg()
.argName("input").required().longOpt("input").build());
options.addOption(Option.builder("out").desc("The output directory or file.").hasArg()
.argName("output").longOpt("output").build());
options.addOption(Option.builder("traversemodeled").desc("Propagate through modeled classes.")
.hasArg(false).build());
options.addOption("modeledtypesonly", false, "Only infer modeled types.");
options.addOption(Option.builder("threadcount")
.desc("The maximum number of threads that should be used.").hasArg()
.argName("thread count").type(Number.class).build());
}
示例11: getOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的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("h", "help", false, "Print help information");
options.addOption(null, "infoport", true, "Port for web UI");
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;
}
示例12: createOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
private static Options createOptions()
{
final Options options = new Options();
final OptionGroup group = new OptionGroup();
group.addOption(new Option("h", "help", false, "Print this help message"));
group.addOption(new Option("i", "input-file", true, "Input file path"));
group.setRequired(true);
options.addOptionGroup(group);
options.addOption("b", "database-file", true, "File to read database from");
options.addOption("e", "epoch-size", true, "Range for epoch size (default " + Parameters.DEFAULT_EPOCH_SIZE
+ ")");
options.addOption("t", "train-threshold", true, "Range for training threshold (default "
+ Parameters.DEFAULT_TRAIN_THRESHOLD + ")");
options.addOption("d", "detection-threshold", true, "Range for detection threshold (default "
+ Parameters.DEFAULT_TEST_THRESHOLD + ")");
options.addOption("v", "verbose", true, "Verbose level (default 0)");
options.addOption("o", "output-file", true, "Output file path");
return options;
}
示例13: CubeMetaExtractor
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
public CubeMetaExtractor() {
super();
OptionGroup realizationOrProject = new OptionGroup();
realizationOrProject.addOption(OPTION_CUBE);
realizationOrProject.addOption(OPTION_PROJECT);
realizationOrProject.addOption(OPTION_HYBRID);
realizationOrProject.addOption(OPTION_All_PROJECT);
realizationOrProject.setRequired(true);
options.addOptionGroup(realizationOrProject);
options.addOption(OPTION_INCLUDE_SEGMENTS);
options.addOption(OPTION_INCLUDE_JOB);
options.addOption(OPTION_INCLUDE_SEGMENT_DETAILS);
options.addOption(OPTION_INCLUDE_ONLY_JOB_OUTPUT);
options.addOption(OPTION_STORAGE_TYPE);
options.addOption(OPTION_ENGINE_TYPE);
}
示例14: buildPa11yOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
public static Options buildPa11yOptions() {
Options options = new Options();
OptionGroup mutuallyExclusiveOptions = new OptionGroup();
mutuallyExclusiveOptions.addOption(getCreateTaskOption());
mutuallyExclusiveOptions.addOption(getListTasksOption());
mutuallyExclusiveOptions.addOption(getRunOption());
mutuallyExclusiveOptions.addOption(getRetrieveTaskOption());
mutuallyExclusiveOptions.addOption(getDeleteTaskOption());
options.addOptionGroup(mutuallyExclusiveOptions);
options.addOption(getNameOption());
options.addOption(getUrlOption());
options.addOption(getStandardOption());
options.addOption(getLastResultOption());
options.addOption(getTaskIdOption());
return options;
}
示例15: testBuildPa11yOptions
import org.apache.commons.cli.OptionGroup; //導入依賴的package包/類
@Test
public void testBuildPa11yOptions() throws Exception {
Options options = OptionsBuilder.buildPa11yOptions();
assertEquals(10, options.getOptions().size());
assertPa11yOptions(options);
OptionGroup optionGroup = options.getOptionGroup(options.getOption("c"));
Collection<String> optionGroupNames = optionGroup.getNames();
assertTrue(optionGroupNames.contains("c"));
assertTrue(optionGroupNames.contains("l"));
assertTrue(optionGroupNames.contains("r"));
assertTrue(optionGroupNames.contains("g"));
assertTrue(optionGroupNames.contains("d"));
}