use of org.apache.commons.cli.Option in project hbase by apache.
the class AbstractHBaseTool method addRequiredOptWithArg.
protected void addRequiredOptWithArg(String shortOpt, String longOpt, String description) {
Option option = new Option(shortOpt, longOpt, true, description);
option.setRequired(true);
addOption(option);
}
use of org.apache.commons.cli.Option in project zm-mailbox by Zimbra.
the class LocalConfigCLI method usage.
/**
* Prints supported usage to stdout. Removes hidden options from the list to be printed
*
*/
private void usage() {
Collection<Object> options = mOptions.getOptions();
Options displayOptions = new Options();
for (Object obj : options) {
// copy over the supported options
// should be a safe cast, this api REALLY needs generics
Option opt = (Option) obj;
if (!"all".equals(opt.getLongOpt())) {
displayOptions.addOption(opt);
}
}
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("zmlocalconfig [options] [args]", "where [options] are:", displayOptions, "");
System.exit(0);
}
use of org.apache.commons.cli.Option in project zm-mailbox by Zimbra.
the class SoapCLI method getAllOptions.
/**
* Returns an <tt>Options</tt> object that combines the standard options
* and the hidden ones.
*/
@SuppressWarnings("unchecked")
private Options getAllOptions() {
Options newOptions = new Options();
Set<OptionGroup> groups = new HashSet<OptionGroup>();
Options[] optionses = new Options[] { mOptions, mHiddenOptions };
for (Options options : optionses) {
for (Option opt : (Collection<Option>) options.getOptions()) {
OptionGroup group = options.getOptionGroup(opt);
if (group != null) {
groups.add(group);
} else {
newOptions.addOption(opt);
}
}
}
for (OptionGroup group : groups) {
newOptions.addOptionGroup(group);
}
return newOptions;
}
use of org.apache.commons.cli.Option in project zm-mailbox by Zimbra.
the class FixCalendarPriorityUtil method setupCommandLineOptions.
protected void setupCommandLineOptions() {
super.setupCommandLineOptions();
Options options = getOptions();
Option accountOpt = new Option(O_ACCOUNT, "account", true, "account email addresses seperated by white space or \"all\" for all accounts");
accountOpt.setArgs(Option.UNLIMITED_VALUES);
options.addOption(accountOpt);
options.addOption(new Option(null, O_SYNC, false, "run synchronously; default is asynchronous"));
options.addOption(SoapCLI.OPT_AUTHTOKEN);
options.addOption(SoapCLI.OPT_AUTHTOKENFILE);
}
use of org.apache.commons.cli.Option in project zm-mailbox by Zimbra.
the class VolumeCLI method printOpt.
private void printOpt(String optStr, int leftPad) {
Options options = getOptions();
Option opt = options.getOption(optStr);
StringBuilder buf = new StringBuilder();
buf.append(Strings.repeat(" ", leftPad));
buf.append('-').append(opt.getOpt()).append(",--").append(opt.getLongOpt());
if (opt.hasArg()) {
buf.append(" <arg>");
}
buf.append(Strings.repeat(" ", 35 - buf.length()));
buf.append(opt.getDescription());
System.err.println(buf.toString());
}
Aggregations