Example usage for org.apache.commons.cli Option Option

List of usage examples for org.apache.commons.cli Option Option

Introduction

In this page you can find the example usage for org.apache.commons.cli Option Option.

Prototype

public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException 

Source Link

Document

Creates an Option using the specified parameters.

Usage

From source file:edu.cornell.med.icb.geo.tools.GDS2InsightfulMiner.java

private void proccess(final String[] args) {
    // create the Options
    final Options options = new Options();

    // help//  w w w.  j  a va  2s .c o m
    options.addOption("h", "help", false, "print this message");

    // input file name
    final Option inputOption = new Option("i", "input", true, "specify a GEO data set file (GDS file)");
    inputOption.setArgName("file");
    inputOption.setRequired(true);
    options.addOption(inputOption);

    // output file name
    final Option outputOption = new Option("o", "output", true, "specify the destination file");
    outputOption.setArgName("file");
    outputOption.setRequired(true);
    options.addOption(outputOption);
    // label values
    final Option labelOptions = new Option("l", "label", true, "specify a label to tag a set of columns");
    labelOptions.setArgName("double-value");
    labelOptions.setRequired(false);
    options.addOption(labelOptions);

    // group file names
    final Option groupOptions = new Option("g", "group", true,
            "specify a file that named columns associated to a label. Each -group option must match a -label option. Matching is done according to the order on the command line. Each line of the group file identifies a column in the GEO data set that is to be labeled according to the corresponding label");
    groupOptions.setArgName("file");
    groupOptions.setRequired(false);
    options.addOption(groupOptions);

    // default label value
    final Option defaultLabelOption = new Option("dl", "default-label", true,
            "Specify the label to use for columns that are not identified by -l -g pairs. Default value is zero.");
    groupOptions.setArgName("double-value");
    groupOptions.setRequired(false);
    options.addOption(defaultLabelOption);
    // parse the command line arguments
    CommandLine line = null;
    double defaultLabelValue = 0;
    try {
        // create the command line parser
        final CommandLineParser parser = new BasicParser();
        line = parser.parse(options, args, true);
        if ((line.hasOption("l") && !line.hasOption("g")) || (line.hasOption("g") && !line.hasOption("l"))) {
            System.err.println("Options -label and -group must be used together.");
            System.exit(10);
        }
        if (line.hasOption("l") && line.getOptionValues("l").length != line.getOptionValues("g").length) {
            System.err.println("The number of -label and -group options must match exactly.");
            System.exit(10);
        }
        if (line.hasOption("dl")) {
            defaultLabelValue = Double.parseDouble(line.getOptionValue("dl"));
        }

    } catch (ParseException e) {
        System.err.println(e.getMessage());
        usage(options);
        System.exit(1);
    }
    // print help and exit
    if (line.hasOption("h")) {
        usage(options);
        System.exit(0);
    }
    try {
        final Map<Double, Set<String>> labels = readLabelGroups(line.getOptionValues("l"),
                line.getOptionValues("g")); //labels
        convert(line.getOptionValue("i"), line.getOptionValue("o"), labels, defaultLabelValue);
        System.exit(0);
    } catch (FileNotFoundException e) {

        System.err.println("Error opening file: \n");
        printGroups(line);
    } catch (IOException e) {
        System.err.println("An error occurred reading one of the group files:\n");
        printGroups(line);
    }

}

From source file:edu.cmu.tetrad.cli.simulation.data.SemRandomForwardCli.java

@Override
public List<Option> getOptionalOptions() {
    List<Option> options = new LinkedList<>();
    options.add(/*from w w w.  j  av  a  2 s  .com*/
            new Option(null, CmdOptions.LATENT, true, CmdOptions.createDescription(ParamAttrs.NUM_LATENTS)));
    options.add(
            new Option(null, CmdOptions.AVG_DEGREE, true, CmdOptions.createDescription(ParamAttrs.AVG_DEGREE)));
    options.add(
            new Option(null, CmdOptions.MAX_DEGREE, true, CmdOptions.createDescription(ParamAttrs.MAX_DEGREE)));
    options.add(new Option(null, CmdOptions.MAX_INDEGREE, true,
            CmdOptions.createDescription(ParamAttrs.MAX_INDEGREE)));
    options.add(new Option(null, CmdOptions.MAX_OUTDEGREE, true,
            CmdOptions.createDescription(ParamAttrs.MAX_OUTDEGREE)));
    options.add(
            new Option(null, CmdOptions.CONNECTED, false, CmdOptions.createDescription(ParamAttrs.CONNECTED)));

    return options;
}

From source file:de.oth.keycloak.util.CheckParams.java

private static Option createOption(String shortS, String longS, boolean args, String descr, boolean required) {
    Option o = new Option(shortS, longS, args, descr);
    o.setRequired(required);//w  ww . j a  v  a 2  s .c  o m
    return o;
}

From source file:eu.scape_project.tool.toolwrapper.core.ToolWrapperCommandline.java

/** Public empty constructor */
public ToolWrapperCommandline() {
    Option opt;//from ww w  . j av a2s . com
    options = new Options();
    opt = new Option("t", "toolspec", true, "toolspec file location");
    opt.setRequired(true);
    options.addOption(opt);
    opt = new Option("o", "outDir", true, "directory where to put the generated artifacts");
    opt.setRequired(true);
    options.addOption(opt);
}

From source file:edu.cmu.tetrad.cli.search.GfcicCli.java

@Override
public List<Option> getOptionalOptions() {
    List<Option> options = super.getOptionalOptions();
    options.add(new Option(null, CmdOptions.ALPHA, true, CmdOptions.getDescription(CmdOptions.ALPHA)));

    return options;
}

From source file:com.google.enterprise.connector.importexport.DumpConnectors.java

@Override
public Options getOptions() {
    Options options = super.getOptions();
    options.addOption("l", "list", false, "List available connectors.");
    Option o = new Option("c", "connector_name", true, "Connector to export.");
    o.setArgName("connector_name");
    options.addOption(o);/* w  w  w  .  j  ava2 s .  c  om*/
    return options;
}

From source file:de.tudarmstadt.lt.lm.app.PerpDoc.java

/**
 * //from  w  w w.j av a2s  .  c om
 */
@SuppressWarnings("static-access")
public PerpDoc(String args[]) {
    Options opts = new Options();

    opts.addOption(new Option("?", "help", false, "display this message"));
    opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg()
            .withDescription(
                    String.format("Specifies the port on which the rmi registry listens (default: %d).",
                            Registry.REGISTRY_PORT))
            .create("p"));
    opts.addOption(OptionBuilder.withLongOpt("selftest")
            .withDescription("Run a selftest, compute perplexity of ngrams in specified LM.").create("s"));
    opts.addOption(OptionBuilder.withLongOpt("quiet").withDescription("Run with minimum outout on stdout.")
            .create("q"));
    opts.addOption(OptionBuilder.withLongOpt("noov").hasOptionalArg().withArgName("{true|false}")
            .withDescription("Do not consider oov terms, i.e. ngrams that end in an oov term. (default: false)")
            .create());
    opts.addOption(OptionBuilder.withLongOpt("oovreflm").withArgName("identifier").hasArg().withDescription(
            "Do not consider oov terms with respect to the provided lm, i.e. ngrams that end in an oov term in the referenced lm. (default use current lm)")
            .create());
    opts.addOption(OptionBuilder.withLongOpt("host").withArgName("hostname").hasArg()
            .withDescription("Specifies the hostname on which the rmi registry listens (default: localhost).")
            .create("h"));
    opts.addOption(OptionBuilder.withLongOpt("file").withArgName("name").hasArg().withDescription(
            "Specify the file or directory that contains '.txt' files that are used as source for testing perplexity with the specified language model. Specify '-' to pipe from stdin. (default: '-').")
            .create("f"));
    opts.addOption(OptionBuilder.withLongOpt("out").withArgName("name").hasArg()
            .withDescription("Specify the output file. Specify '-' to use stdout. (default: '-').")
            .create("o"));
    opts.addOption(OptionBuilder.withLongOpt("name").withArgName("identifier").isRequired().hasArg()
            .withDescription("Specify the name of the language model provider that you want to connect to.")
            .create("i"));

    try {
        CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
        if (cmd.hasOption("help"))
            CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0);

        _host = cmd.getOptionValue("host", "localhost");
        _rmiport = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT)));
        _file = cmd.getOptionValue("file", "-");
        _out = cmd.getOptionValue("out", "-");
        _name = cmd.getOptionValue("name");
        _host = cmd.getOptionValue("host", "localhost");
        _selftest = cmd.hasOption("selftest");
        _quiet = cmd.hasOption("quiet");
        _no_oov = cmd.hasOption("noov");
        if (_no_oov && cmd.getOptionValue("noov") != null)
            _no_oov = Boolean.parseBoolean(cmd.getOptionValue("noov"));
        _oovreflm_name = cmd.getOptionValue("oovreflm");

    } catch (Exception e) {
        LOG.error("{}: {}- {}", _rmi_string, e.getClass().getSimpleName(), e.getMessage());
        CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER,
                String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
    }
    _rmi_string = String.format("rmi://%s:%d/%s", _host, _rmiport, _name);
}

From source file:com.opengamma.integration.tool.marketdata.manipulator.dsl.SaveScenario.java

@Override
protected Options createOptions(boolean mandatoryConfigResource) {
    Options options = super.createOptions(mandatoryConfigResource);

    Option scriptLocation = new Option("s", SCRIPT_LOCATION, true,
            "Location of the scenario script on the filesystem");
    scriptLocation.setRequired(true);//from  w  w  w. j av  a 2s.c  o  m
    options.addOption(scriptLocation);

    Option scenarioId = new Option("i", SCENARIO_ID, true,
            "Object ID of the scenario definition. Omit to save as " + "a new definition");
    options.addOption(scenarioId);

    return options;
}

From source file:com.buildml.main.commands.CliCommandShowDerivedFiles.java

@Override
public Options getOptions() {

    /* start with the standard show-files options */
    Options opts = super.getOptions();

    /* add the --all option */
    Option allOpt = new Option("a", "all", false, "Also show indirectly derived files.");
    opts.addOption(allOpt);/*from   w  w w  . jav  a2s.co  m*/

    return opts;
}

From source file:com.netscape.cmstools.pkcs12.PKCS12CertImportCLI.java

public void createOptions() {
    Option option = new Option(null, "pkcs12-file", true, "PKCS #12 file");
    option.setArgName("path");
    options.addOption(option);//from   w  w  w .  j  ava 2 s. c  o m

    option = new Option(null, "pkcs12-password", true, "PKCS #12 password");
    option.setArgName("password");
    options.addOption(option);

    option = new Option(null, "pkcs12-password-file", true, "PKCS #12 password file");
    option.setArgName("path");
    options.addOption(option);

    option = new Option(null, "friendly-name", true, "Friendly name for the certificate in PKCS #12");
    option.setArgName("name");
    options.addOption(option);

    option = new Option(null, "cert-encryption", true,
            "Certificate encryption algorithm (default: " + PKCS12Util.DEFAULT_CERT_ENCRYPTION_NAME + ").");
    option.setArgName("algorithm");
    options.addOption(option);

    option = new Option(null, "key-encryption", true,
            "Key encryption algorithm (default: " + PKCS12Util.DEFAULT_KEY_ENCRYPTION_NAME + ").");
    option.setArgName("algorithm");
    options.addOption(option);

    options.addOption(null, "append", false, "Import into an existing PKCS #12 file");
    options.addOption(null, "no-trust-flags", false, "Do not include trust flags");
    options.addOption(null, "no-key", false, "Do not include private key");
    options.addOption(null, "no-chain", false, "Do not include certificate chain");

    options.addOption("v", "verbose", false, "Run in verbose mode.");
    options.addOption(null, "debug", false, "Run in debug mode.");
    options.addOption(null, "help", false, "Show help message.");
}