use of org.apache.commons.cli.Options in project zm-mailbox by Zimbra.
the class LocalConfigUpgrade method usage.
static void usage(String error) {
if (error != null)
System.out.println("Error: " + error);
Options opts = getAllOptions();
PrintWriter pw = new PrintWriter(System.out, true);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(pw, formatter.getWidth(), getCommandUsage(), null, opts, formatter.getLeftPadding(), formatter.getDescPadding(), null);
pw.flush();
if (error != null) {
System.exit(1);
} else {
System.exit(0);
}
}
use of org.apache.commons.cli.Options in project zm-mailbox by Zimbra.
the class RandomPassword method main.
public static void main(String[] args) {
CommandLineParser parser = new GnuParser();
Options options = new Options();
options.addOption("l", "localpart", false, "generated string does not contain dot(.)");
CommandLine cl = null;
boolean err = false;
try {
cl = parser.parse(options, args, true);
} catch (ParseException pe) {
System.err.println("error: " + pe.getMessage());
err = true;
}
if (err || cl.hasOption('h')) {
usage();
}
boolean localpart = false;
int minLength = DEFAULT_MIN_LENGTH;
int maxLength = DEFAULT_MAX_LENGTH;
if (cl.hasOption('l'))
localpart = true;
args = cl.getArgs();
if (args.length != 0) {
if (args.length != 2) {
usage();
}
try {
minLength = Integer.valueOf(args[0]).intValue();
maxLength = Integer.valueOf(args[1]).intValue();
} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
}
}
System.out.println(generate(minLength, maxLength, localpart));
}
use of org.apache.commons.cli.Options in project zm-mailbox by Zimbra.
the class ChartUtil method getOptions.
private static Options getOptions() {
Options opts = new Options();
opts.addOption("h", OPT_HELP, false, "prints this usage screen");
Option confOption = new Option("c", OPT_CONF, true, "chart configuration xml files");
confOption.setArgs(Option.UNLIMITED_VALUES);
confOption.setRequired(true);
opts.addOption(confOption);
Option srcDirOption = new Option("s", OPT_SRCDIR, true, "one or more directories where the csv files are located");
srcDirOption.setArgs(Option.UNLIMITED_VALUES);
opts.addOption(srcDirOption);
Option destDirOption = new Option("d", OPT_DESTDIR, true, "directory where the generated chart files are saved");
opts.addOption(destDirOption);
opts.addOption(null, OPT_TITLE, true, "chart title; defaults to last directory name of --" + OPT_SRCDIR + " value");
opts.addOption(null, OPT_START_AT, true, "if specified, ignore all samples before this timestamp (MM/dd/yyyy HH:mm:ss)");
opts.addOption(null, OPT_END_AT, true, "if specified, ignore all samples after this timestamp (MM/dd/yyyy HH:mm:ss)");
opts.addOption(null, OPT_AGGREGATE_START_AT, true, "if specified, aggregate computation starts at this timestamp (MM/dd/yyyy HH:mm:ss)");
opts.addOption(null, OPT_AGGREGATE_END_AT, true, "if specified, aggregate computation ends at this timestamp (MM/dd/yyyy HH:mm:ss)");
opts.addOption(null, OPT_NO_SUMMARY, false, "skip summary data generation");
return opts;
}
use of org.apache.commons.cli.Options in project zm-mailbox by Zimbra.
the class SoapApiChangeLog method main.
/**
* Main
*/
public static void main(String[] args) throws Exception {
CommandLineParser parser = new PosixParser();
Options options = new Options();
Option opt;
opt = new Option("d", ARG_OUTPUT_DIR, true, "Output directory for changelog information");
opt.setRequired(true);
options.addOption(opt);
opt = new Option("t", ARG_TEMPLATES_DIR, true, "Directory containing Freemarker templates");
opt.setRequired(true);
options.addOption(opt);
opt = new Option("b", ARG_APIDESC_BASELINE_JSON, true, "JSON file - description of baseline SOAP API");
opt.setRequired(true);
options.addOption(opt);
opt = new Option("c", ARG_APIDESC_CURRENT_JSON, true, "JSON file - description of current SOAP API");
opt.setRequired(true);
options.addOption(opt);
CommandLine cl = null;
try {
cl = parser.parse(options, args, true);
} catch (ParseException pe) {
System.err.println("error: " + pe.getMessage());
System.exit(2);
}
String baselineApiDescriptionJson = cl.getOptionValue('b');
String currentApiDescriptionJson = cl.getOptionValue('c');
SoapApiChangeLog clog = new SoapApiChangeLog(cl.getOptionValue('d'), cl.getOptionValue('t'));
clog.setBaselineDesc(SoapApiDescription.deserializeFromJson(new File(baselineApiDescriptionJson)));
clog.setCurrentDesc(SoapApiDescription.deserializeFromJson(new File(currentApiDescriptionJson)));
clog.makeChangeLogDataModel();
clog.writeChangelog();
}
use of org.apache.commons.cli.Options in project shifu by ShifuML.
the class ShifuCLI method buildModelSetOptions.
@SuppressWarnings("static-access")
private static Options buildModelSetOptions(String[] args) {
Options opts = new Options();
Option opt_cmt = OptionBuilder.hasArg().withDescription("The description for new model").create(MODELSET_CMD_M);
Option opt_new = OptionBuilder.hasArg().withDescription("To create an eval set").create(NEW);
Option opt_type = OptionBuilder.hasArg().withDescription("Specify model type").create(MODELSET_CMD_TYPE);
Option opt_run = OptionBuilder.hasOptionalArg().withDescription("To run eval set").create(EVAL_CMD_RUN);
Option opt_dry = OptionBuilder.hasArg(false).withDescription("Dry run the train").create(TRAIN_CMD_DRY);
Option opt_debug = OptionBuilder.hasArg(false).withDescription("Save the log of train process").create(TRAIN_CMD_DEBUG);
Option opt_model = OptionBuilder.hasArg(false).withDescription("Init model").create(INIT_CMD_MODEL);
Option opt_concise = OptionBuilder.hasArg(false).withDescription("Export concise PMML").create(EXPORT_CONCISE);
Option opt_reset = OptionBuilder.hasArg(false).withDescription("Reset all variables to finalSelect = false").create(RESET);
Option opt_correlation = OptionBuilder.hasArg(false).withDescription("Compute corrlation value for all column pairs.").create(CORRELATION);
Option opt_correlation_short = OptionBuilder.hasArg(false).withDescription("Compute corrlation value for all column pairs.").create("c");
Option opt_shuffle = OptionBuilder.hasArg(false).withDescription("Shuffle data after normalization").create(SHUFFLE);
Option opt_resume = OptionBuilder.hasArg(false).withDescription("Resume combo model training.").create(RESUME);
Option opt_list = OptionBuilder.hasArg(false).create(LIST);
Option opt_delete = OptionBuilder.hasArg().create(DELETE);
Option opt_score = OptionBuilder.hasArg().create(SCORE);
Option opt_confmat = OptionBuilder.hasArg().create(CONFMAT);
Option opt_perf = OptionBuilder.hasArg().create(PERF);
Option opt_norm = OptionBuilder.hasArg().create(NORM);
Option opt_eval = OptionBuilder.hasArg(false).create(EVAL_CMD);
Option opt_init = OptionBuilder.hasArg(false).create(INIT_CMD);
Option opt_rebin = OptionBuilder.hasArg(false).create(REBIN);
Option opt_vars = OptionBuilder.hasArg().create(VARS);
Option opt_n = OptionBuilder.hasArg().create(N);
Option opt_ivr = OptionBuilder.hasArg().create(IVR);
Option opt_bic = OptionBuilder.hasArg().create(BIC);
Option opt_save = OptionBuilder.hasArg(false).withDescription("save model").create(SAVE);
Option opt_switch = OptionBuilder.hasArg(false).withDescription("switch model").create(SWITCH);
Option opt_eval_model = OptionBuilder.hasArg().withDescription("").create(EVAL_MODEL);
opts.addOption(opt_cmt);
opts.addOption(opt_new);
opts.addOption(opt_type);
opts.addOption(opt_run);
opts.addOption(opt_perf);
opts.addOption(opt_norm);
opts.addOption(opt_dry);
opts.addOption(opt_debug);
opts.addOption(opt_model);
opts.addOption(opt_concise);
opts.addOption(opt_reset);
opts.addOption(opt_eval);
opts.addOption(opt_init);
opts.addOption(opt_shuffle);
opts.addOption(opt_resume);
opts.addOption(opt_list);
opts.addOption(opt_delete);
opts.addOption(opt_score);
opts.addOption(opt_confmat);
opts.addOption(opt_save);
opts.addOption(opt_switch);
opts.addOption(opt_eval_model);
opts.addOption(opt_correlation);
opts.addOption(opt_correlation_short);
opts.addOption(opt_rebin);
opts.addOption(opt_vars);
opts.addOption(opt_n);
opts.addOption(opt_ivr);
opts.addOption(opt_bic);
return opts;
}
Aggregations