下面列出了org.apache.commons.cli.Option#setLongOpt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static Option registerTaskOption(String opt, String longOpt, String description, int numArgs, LockId... lockIds) {
Option option = OptionBuilder.create(opt);
option.setRequired(false);
option.setDescription("task: " + description);
option.setLongOpt(longOpt);
option.setArgs(numArgs);
taskOptionMap.put(opt, option);
LinkedHashSet<LockId> taskLockIdMap = new LinkedHashSet<LockId>();
if (lockIds != null) {
for (int i = 0; i < lockIds.length; i++) {
if (lockIds[i] != null) {
taskLockIdMap.add(lockIds[i]);
}
}
}
taskLockIdsMap.put(opt, taskLockIdMap);
return option;
}
private Options populateValidOptions() {
Options validOptions = new Options();
validOptions.addOption("schema", false, "Loads / Stores the schema of the relation using a hidden JSON file.");
validOptions.addOption("noschema", false, "Disable attempting to load data schema from the filesystem.");
validOptions.addOption(TAG_SOURCE_FILE, false, "Appends input source file name to beginning of each tuple.");
validOptions.addOption(TAG_SOURCE_PATH, false, "Appends input source file path to beginning of each tuple.");
validOptions.addOption("tagsource", false, "Appends input source file name to beginning of each tuple.");
Option overwrite = new Option(" ", "Overwrites the destination.");
overwrite.setLongOpt("overwrite");
overwrite.setOptionalArg(true);
overwrite.setArgs(1);
overwrite.setArgName("overwrite");
validOptions.addOption(overwrite);
return validOptions;
}
/**
* Creates an Option using OptionBuilder's State and the given parameters.
*
* @param opt
* short representation of the option
* @param longOpt
* long representation of the option
* @param desc
* descibes the function of the option
* @return the new Option
*/
public Option create(final String opt, final String longOpt, final String desc) {
final Option option = new Option(opt, desc);
option.setLongOpt(longOpt);
option.setArgs(args);
option.setRequired(required);
option.setOptionalArg(optionalArg);
option.setType(type);
option.setValueSeparator(valSeparator);
return option;
}
private static Option registerOptionalOption(String opt, String longOpt, String description, int numArgs) {
Option option = OptionBuilder.create(opt);
option.setRequired(false);
option.setDescription("option: " + description);
option.setLongOpt(longOpt);
option.setArgs(numArgs);
optionalOptionMap.put(opt, option);
return option;
}
private Option createAnOption(String[] argInfo)
{
Option opt = new Option(argInfo[0], argInfo[2]);
if (!isStringEmpty(argInfo[1]))
{
opt.setLongOpt(argInfo[1]);
}
return opt;
}
private Option createAnOptionWithArgument(String[] argInfo)
{
OptionBuilder.withArgName(argInfo[0]);
OptionBuilder.hasArg();
OptionBuilder.withDescription(argInfo[2]);
Option opt = OptionBuilder.create( argInfo[0]);
if (!isStringEmpty(argInfo[1]))
{
opt.setLongOpt(argInfo[1]);
}
return opt;
}
private OptionBuilder(String shortName, String longName) {
option = new Option(shortName, "");
option.setLongOpt(longName);
option.setArgName(longName);
}