Search in sources :

Example 46 with Options

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);
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) PrintWriter(java.io.PrintWriter)

Example 47 with Options

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));
}
Also used : Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) ParseException(org.apache.commons.cli.ParseException)

Example 48 with Options

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;
}
Also used : Options(org.apache.commons.cli.Options) Option(org.apache.commons.cli.Option)

Example 49 with Options

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();
}
Also used : Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) PosixParser(org.apache.commons.cli.PosixParser) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) JsonParseException(org.codehaus.jackson.JsonParseException) ParseException(org.apache.commons.cli.ParseException) File(java.io.File)

Example 50 with Options

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;
}
Also used : Options(org.apache.commons.cli.Options) Option(org.apache.commons.cli.Option)

Aggregations

Options (org.apache.commons.cli.Options)1086 CommandLine (org.apache.commons.cli.CommandLine)557 CommandLineParser (org.apache.commons.cli.CommandLineParser)382 ParseException (org.apache.commons.cli.ParseException)341 Option (org.apache.commons.cli.Option)325 HelpFormatter (org.apache.commons.cli.HelpFormatter)275 GnuParser (org.apache.commons.cli.GnuParser)207 DefaultParser (org.apache.commons.cli.DefaultParser)166 Test (org.junit.Test)148 PosixParser (org.apache.commons.cli.PosixParser)135 IOException (java.io.IOException)118 File (java.io.File)97 OptionGroup (org.apache.commons.cli.OptionGroup)56 DMLScript (org.apache.sysml.api.DMLScript)56 Path (org.apache.hadoop.fs.Path)54 ArrayList (java.util.ArrayList)38 BasicParser (org.apache.commons.cli.BasicParser)36 Properties (java.util.Properties)33 Configuration (org.apache.hadoop.conf.Configuration)31 FileInputStream (java.io.FileInputStream)29