本文整理了Java中org.apache.commons.cli.Option.<init>()
方法的一些代码示例,展示了Option.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.<init>()
方法的具体详情如下:
包路径:org.apache.commons.cli.Option
类名称:Option
方法名:<init>
[英]Creates an Option using the specified parameters.
[中]使用指定的参数创建选项。
代码示例来源:origin: apache/rocketmq
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("i", "messageId", true, "unique message ID");
opt.setRequired(false);
options.addOption(opt);
return options;
}
代码示例来源:origin: apache/flink
private static Options buildGeneralOptions(Options options) {
options.addOption(HELP_OPTION);
// backwards compatibility: ignore verbose flag (-v)
options.addOption(new Option("v", "verbose", false, "This option is deprecated."));
return options;
}
代码示例来源:origin: databricks/learning-spark
private static Options createOptions() {
Options options = new Options();
options.addOption(
new Option(WINDOW_LENGTH, false, "The window length in seconds"));
options.addOption(
new Option(SLIDE_INTERVAL, false, "The slide interval in seconds"));
options.addOption(
new Option(LOGS_DIRECTORY, true, "The directory where logs are written"));
options.addOption(
new Option(OUTPUT_HTML_FILE, false, "Where to write output html file"));
options.addOption(
new Option(CHECKPOINT_DIRECTORY, false, "The checkpoint directory."));
options.addOption(new Option(INDEX_HTML_TEMPLATE, true,
"path to the index.html.template file - accessible from all workers"));
options.addOption(new Option(OUTPUT_DIRECTORY, false, "path to output DSTreams too"));
return options;
}
代码示例来源:origin: stackoverflow.com
Options options = new Options();
Option input = new Option("i", "input", true, "input file path");
input.setRequired(true);
options.addOption(input);
Option output = new Option("o", "output", true, "output file");
output.setRequired(true);
options.addOption(output);
代码示例来源:origin: commons-cli/commons-cli
@Test
public void testPropertyOptionGroup() throws Exception
{
Options opts = new Options();
OptionGroup group1 = new OptionGroup();
group1.addOption(new Option("a", null));
group1.addOption(new Option("b", null));
opts.addOptionGroup(group1);
OptionGroup group2 = new OptionGroup();
group2.addOption(new Option("x", null));
group2.addOption(new Option("y", null));
opts.addOptionGroup(group2);
String[] args = new String[] { "-a" };
Properties properties = new Properties();
properties.put("b", "true");
properties.put("x", "true");
CommandLine cmd = parse(parser, opts, args, properties);
assertTrue(cmd.hasOption("a"));
assertFalse(cmd.hasOption("b"));
assertTrue(cmd.hasOption("x"));
assertFalse(cmd.hasOption("y"));
}
}
代码示例来源:origin: dreamhead/moco
protected final Option configOption() {
Option opt = new Option("c", true, "config");
opt.setType(String.class);
opt.setRequired(false);
return opt;
}
代码示例来源:origin: code4craft/webmagic
private static Params parseCommand(String[] args) {
try {
Options options = new Options();
options.addOption(new Option("l", "language", true, "language"));
options.addOption(new Option("t", "thread", true, "thread"));
options.addOption(new Option("f", "file", true, "script file"));
options.addOption(new Option("i", "input", true, "input file"));
options.addOption(new Option("s", "sleep", true, "sleep time"));
options.addOption(new Option("g", "logger", true, "sleep time"));
CommandLineParser commandLineParser = new PosixParser();
CommandLine commandLine = commandLineParser.parse(options, args);
return readOptions(commandLine);
} catch (Exception e) {
e.printStackTrace();
exit();
return null;
}
}
代码示例来源:origin: apache/rocketmq
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
opt.setRequired(true);
options.addOption(opt);
return options;
}
代码示例来源:origin: apache/incubator-gobblin
private Options createCommandLineOptions() {
Options options = new Options();
OptionGroup actionGroup = new OptionGroup();
actionGroup.addOption(new Option("h", HELP_OPT, false, "Shows the help message."));
actionGroup.addOption(new Option("d", DETAILS_OPT, false, "Show details about a job/task."));
actionGroup.addOption(new Option("l", LIST_OPT, false, "List jobs/tasks."));
actionGroup.addOption(new Option("p", PROPS_OPT, false, "Fetch properties with the query."));
actionGroup.setRequired(true);
options.addOptionGroup(actionGroup);
OptionGroup idGroup = new OptionGroup();
idGroup.addOption(new Option("j", NAME_OPT, true, "Find job(s) matching given job name."));
idGroup.addOption(new Option("i", ID_OPT, true, "Find the job/task with the given id."));
options.addOptionGroup(idGroup);
options.addOption("n", true, "Limit the number of results returned. (default:" + DEFAULT_RESULTS_LIMIT + ")");
options.addOption("r", RECENT_OPT, false, "List the most recent jobs (instead of a list of unique jobs)");
return options;
}
代码示例来源:origin: apache/hive
private void init() {
try {
cmdLineOptions.addOption(new Option("help", "Generates a script to execute on 3.x " +
"cluster. This requires 3.x binaries on the classpath and hive-site.xml."));
Option exec = new Option("execute",
"Executes commands equivalent to generated scrips");
exec.setOptionalArg(true);
cmdLineOptions.addOption(exec);
cmdLineOptions.addOption(new Option("location", true,
"Location to write scripts to. Default is CWD."));
}
catch(Exception ex) {
LOG.error("init()", ex);
throw ex;
}
}
private static IMetaStoreClient getHMS(HiveConf conf) {
代码示例来源:origin: apache/ignite
/**
* Creates cli options.
*
* @return Command line options
*/
private static Options createOptions() {
Options options = new Options();
OptionGroup grp = new OptionGroup();
grp.setRequired(true);
Option cfg = new Option(OPTION_CFG, null, true, "path to Spring XML configuration file.");
cfg.setArgName("file");
Option n = new Option(null, OPTION_N, true, "nodes count.");
n.setValueSeparator('=');
n.setType(Integer.class);
grp.addOption(cfg);
grp.addOption(n);
options.addOptionGroup(grp);
return options;
}
}
代码示例来源:origin: dreamhead/moco
protected final Option httpsCertificate() {
Option option = new Option(null, "https", true, "Https certificate filename");
option.setType(String.class);
option.setRequired(false);
return option;
}
代码示例来源:origin: stackoverflow.com
Options options = new Options();
Option option = new Option("c", "c desc");
// Set option c to take 1 to oo arguments
option.setArgs(Option.UNLIMITED_VALUES);
options.addOption(option);
代码示例来源:origin: apache/rocketmq
@Override
public Options buildCommandlineOptions(final Options options) {
Option opt = new Option("b", "brokerAddr", true, "update which broker");
opt.setRequired(false);
options.addOption(opt);
opt = new Option("c", "clusterName", true, "update which cluster");
opt.setRequired(false);
options.addOption(opt);
return options;
}
代码示例来源:origin: apache/flume
public static void main(String[] args) throws Exception {
Options options = new Options();
Option opt = new Option("c", true, "checkpoint directory");
opt.setRequired(true);
options.addOption(opt);
opt = new Option("l", true, "comma-separated list of log directories");
opt.setRequired(true);
options.addOption(opt);
options.addOption(opt);
opt = new Option("t", true, "capacity of the channel");
opt.setRequired(true);
options.addOption(opt);
CommandLineParser parser = new GnuParser();
代码示例来源:origin: apache/incubator-gobblin
private static Options initOptions(Options options) {
options.addOption(new Option(StringUtils.EMPTY + HELP_OPTION, "print this message"));
options.addOption(Option.builder(StringUtils.EMPTY + PLAIN_PWD_OPTION).argName("plain password").hasArg()
.desc("plain password to be encrypted").build());
options.addOption(Option.builder(StringUtils.EMPTY + MASTER_PWD_OPTION).argName("master password").hasArg()
.desc("master password used to encrypt the plain password").build());
options.addOption(Option.builder(StringUtils.EMPTY + MASTER_PWD_FILE_OPTION).argName("master password file")
.hasArg().desc("file that contains the master password used to encrypt the plain password").build());
options.addOption(new Option(StringUtils.EMPTY + STRONG_ENCRYPTOR_OPTION, "use strong encryptor"));
options.addOption(Option.builder(StringUtils.EMPTY + ENCRYPTED_PWD_OPTION).argName("decrypt the input").hasArg().build());
return options;
}
代码示例来源:origin: dreamhead/moco
protected final Option envOption() {
Option opt = new Option("e", true, "environment");
opt.setType(String.class);
opt.setRequired(false);
return opt;
}
代码示例来源:origin: apache/zookeeper
private static TxnLogToolkit parseCommandLine(String[] args) throws TxnLogToolkitException, FileNotFoundException {
CommandLineParser parser = new PosixParser();
Options options = new Options();
Option helpOpt = new Option("h", "help", false, "Print help message");
options.addOption(helpOpt);
Option recoverOpt = new Option("r", "recover", false, "Recovery mode. Re-calculate CRC for broken entries.");
options.addOption(recoverOpt);
Option quietOpt = new Option("v", "verbose", false, "Be verbose in recovery mode: print all entries, not just fixed ones.");
options.addOption(quietOpt);
Option dumpOpt = new Option("d", "dump", false, "Dump mode. Dump all entries of the log file with printing the content of a nodepath (default)");
options.addOption(dumpOpt);
Option forceOpt = new Option("y", "yes", false, "Non-interactive mode: repair all CRC errors without asking");
options.addOption(forceOpt);
Option chopOpt = new Option("c", "chop", false, "Chop mode. Chop txn file to a zxid.");
Option zxidOpt = new Option("z", "zxid", true, "Used with chop. Zxid to which to chop.");
options.addOption(chopOpt);
options.addOption(zxidOpt);
代码示例来源:origin: apache/rocketmq
public static Options buildCommandlineOptions(final Options options) {
Option opt = new Option("h", "help", false, "Print help");
opt.setRequired(false);
options.addOption(opt);
opt =
new Option("n", "namesrvAddr", true,
"Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876");
opt.setRequired(false);
options.addOption(opt);
return options;
}
代码示例来源:origin: apache/hive
@SuppressWarnings("static-access")
private Options createOptions(OptionGroup additionalOptions) {
Option help = new Option("help", "print this message");
Option infoOpt = new Option("info", "Show config and schema details");
Option upgradeOpt = new Option("upgradeSchema", "Schema upgrade");
Option upgradeFromOpt = OptionBuilder.withArgName("upgradeFrom").hasArg()
.withDescription("Schema upgrade from a version")
.create("upgradeSchemaFrom");
Option initOpt = new Option("initSchema", "Schema initialization");
Option initToOpt = OptionBuilder.withArgName("initTo").hasArg()
.withDescription("Schema initialization to a version")
.create("initSchemaTo");
Option initOrUpgradeSchemaOpt = new Option("initOrUpgradeSchema", "Initialize or upgrade schema to latest version");
Option validateOpt = new Option("validate", "Validate the database");
Option createCatalog = OptionBuilder
.hasArg()
" parameters as well.")
.create("moveTable");
Option createUserOpt = new Option("createUser", "Create the Hive user, set hiveUser to the db" +
" admin user and the hive password to the db admin password with this");
.hasArgs().withDescription("Backend DB specific options")
.create("dbOpts");
Option dryRunOpt = new Option("dryRun", "list SQL scripts (no execute)");
Option verboseOpt = new Option("verbose", "only print SQL statements");
Option serversOpt = OptionBuilder.withArgName("serverList")
.hasArgs().withDescription("a comma-separated list of servers used in location validation in the format of " +
内容来源于网络,如有侵权,请联系作者删除!