use of org.apache.commons.cli.Options 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.Options 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.Options in project zm-mailbox by Zimbra.
the class SoapCLI method getCommandLine.
/**
* Parses the command line arguments. If -h,--help is specified, displays usage and returns null.
* @param args the command line arguments
* @return
* @throws ParseException
*/
protected CommandLine getCommandLine(String[] args) throws ParseException {
CommandLineParser clParser = new GnuParser();
CommandLine cl = null;
Options opts = getAllOptions();
try {
cl = clParser.parse(opts, args);
} catch (ParseException e) {
if (helpOptionSpecified(args)) {
usage();
return null;
} else
throw e;
}
if (cl.hasOption(O_H)) {
boolean showHiddenOptions = cl.hasOption(O_HIDDEN);
usage(null, showHiddenOptions);
return null;
}
if (!mDisableTargetServerOption && cl.hasOption(O_S))
setServer(cl.getOptionValue(O_S));
return cl;
}
use of org.apache.commons.cli.Options in project zm-mailbox by Zimbra.
the class PlaybackUtil method usage.
private static void usage(String errmsg) {
if (errmsg != null) {
System.err.println(errmsg);
}
String usage = "zmplayredo <options>";
Options opts = sOptions;
PrintWriter pw = new PrintWriter(System.err, true);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(pw, formatter.getWidth(), usage, null, opts, formatter.getLeftPadding(), formatter.getDescPadding(), null);
pw.flush();
String trailer = SoapCLI.getAllowedDatetimeFormatsHelp();
if (trailer != null && trailer.length() > 0) {
System.err.println();
System.err.println(trailer);
}
}
use of org.apache.commons.cli.Options in project phoenix by apache.
the class RegexBulkLoadTool method getOptions.
@Override
protected Options getOptions() {
Options options = super.getOptions();
options.addOption(REGEX_OPT);
options.addOption(ARRAY_DELIMITER_OPT);
return options;
}
Aggregations