}
/**
* Adds an option instance
*
* @param opt the option that is to be added
* @return the resulting Options instance
*/
public Options addOption(Option opt)
{
String key = opt.getKey();
// add it to the long option list
if (opt.hasLongOpt())
{
longOpts.put(opt.getLongOpt(), opt);
}
// if the option is required add it to the required list
if (opt.isRequired())
{
if (requiredOpts.contains(key))
{
requiredOpts.remove(requiredOpts.indexOf(key));
}
requiredOpts.add(key);
}
shortOpts.put(key, opt);
return this;
}
Options |
addOption(Option opt) Adds an option instance |
Options |
addOption(String opt, boolean hasArg, String description) Add an option that only contains a short-name. |
没看出来两个有啥区别,我今天用第二个,出错,现在怀疑是脚本问题