Example usage for org.apache.commons.cli OptionBuilder withLongOpt

List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt

Introduction

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

Prototype

public static OptionBuilder withLongOpt(String newLongopt) 

Source Link

Document

The next Option created will have the following long option value.

Usage

From source file:cognition.pipeline.commandline.CommandRunFromFileSystem.java

@Override
public void addOption(Options options) {
    options.addOption(OptionBuilder.withLongOpt("folder")
            .withDescription("The absolute path of the folder in which binary files reside").hasArg()
            .withArgName("folder").create());
}

From source file:cognition.pipeline.commandline.CommandClient.java

@Override
public void addOption(Options options) {
    options.addOption(OptionBuilder.withLongOpt("client")
            .withDescription("Application runs as a client of a coordinator web server.").withArgName("client")
            .create())/*from www. jav  a 2 s  .  co  m*/
            .addOption(
                    OptionBuilder.withLongOpt("server").withDescription("The address of the coordinator server")
                            .hasArg().withArgName("server").create())
            .addOption(
                    OptionBuilder.withLongOpt("cognitionName").withDescription("Cognition name of the computer")
                            .hasArg().withArgName("cognitionName").create())
            .addOption(OptionBuilder.withLongOpt("chunkSize")
                    .withDescription("Number of work coordinates to ask from server.").hasArg()
                    .withArgName("chunkSize").create());
}

From source file:com.schatzforensic.byteplotter.Main.java

/**
 * Main run point./*  ww w.j a  v a 2  s  .  c  o  m*/
 * 
 * @param args The command line arguments.
 */
@SuppressWarnings("static-access")
public void run(String[] args) {
    System.out.println(APPLICATON_HEADER);

    // Parse the CLI to find out if we are attempting to identify the relocations, or just plotting the NAND.
    CommandLineParser parser = new BasicParser();
    Options options = new Options();
    //options.addOption("l", "locate-relocations", false, "Attempt to location relocations the NAND");
    options.addOption("p", "byteplot", false, "Byte Plot the NAND file (default operation)");
    options.addOption("?", "help", false, "print this message");
    options.addOption("v", "version", false, "version information");
    options.addOption(OptionBuilder.withLongOpt("file").withDescription("NAND raw image file")
            .withArgName("FILE").hasArg().create("f"));
    options.addOption("l", "spare-location", true, "The location of spare: inband or end (default)");
    options.addOption(OptionBuilder.withLongOpt("userdata-size").withDescription("use SIZE-byte blocks")
            .hasArg().withArgName("SIZE").create());
    options.addOption(OptionBuilder.withLongOpt("spare-size").withDescription("use SIZE-byte spare blocks")
            .hasArg().withArgName("SIZE").create());
    options.addOption(OptionBuilder.withLongOpt("tile-size").withDescription("use SIZE-byte tile").hasArg()
            .withArgName("SIZE").create());

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        // Mandatory
        String filename = getString(line, "file");
        int userDataSize = getInteger(line, "userdata-size");
        int spareSize = getInteger(line, "spare-size");

        // Optional
        boolean spareNotInband = true;
        if (line.hasOption("spare-location")) {
            String val = line.getOptionValue("spare-location");
            if (val.equals("inband")) {
                spareNotInband = false;
            } else if (val.equals("end")) {
                spareNotInband = true;
            } else {
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("byteplot", options);
                System.exit(0);
            }
        }

        boolean plot = true;
        //         if (line.hasOption("l")) {
        //            plot = false;
        //         }

        // Help and Version.
        if (line.hasOption("v")) {
            System.out.println("Version 1.0.0.0");
        }
        if (line.hasOption("?")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("byteplot", options);
            System.exit(0);
        }

        if (plot) {
            int tile = getInteger(line, "tile-size");
            new NANDBytePlot(filename, userDataSize, spareSize, tile, spareNotInband);
        } else {
            new IdentifyRelocations(filename, userDataSize, spareSize, spareNotInband);
        }

    } catch (ParseException exp) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("byteplot", options);
        System.exit(0);
    } catch (NumberFormatException exp) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("byteplot", options);
        System.exit(0);
    }
}

From source file:eu.stratosphere.myriad.driver.MyriadDriverFrontend.java

public MyriadDriverFrontend() {
    // dgen-install-dir
    this.options = new Options();

    // scaling-factor
    OptionBuilder.hasArg();//from  ww w .java2 s  . c  o m
    OptionBuilder.withArgName("double");
    OptionBuilder.withDescription("scaling factor (s=1 generates 1GB)");
    OptionBuilder.withLongOpt("scaling-factor");
    this.options.addOption(OptionBuilder.create('s'));

    // dataset-id
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("string");
    OptionBuilder.withDescription("ID of the generated Myriad dataset");
    OptionBuilder.withLongOpt("dataset-id");
    this.options.addOption(OptionBuilder.create('m'));

    // node-count
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("int");
    OptionBuilder.withDescription("degree of parallelism (i.e. total number of partitions)");
    OptionBuilder.withArgName("node-count");
    this.options.addOption(OptionBuilder.create('N'));

    // output-base
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("path");
    OptionBuilder.withDescription("base path for writing the output");
    OptionBuilder.withLongOpt("output-base");
    this.options.addOption(OptionBuilder.create('o'));

    // execute-stages
    OptionBuilder.hasArgs();
    OptionBuilder.withArgName("stagename");
    OptionBuilder.withDescription("specify specific stages to be executed");
    OptionBuilder.withLongOpt("execute-stage");
    this.options.addOption(OptionBuilder.create('x'));
}

From source file:PSOResultFileMerger.java

@SuppressWarnings("static-access")
@Override//from   ww  w  . j a  v a 2 s . c  o m
public Options getOptions() {
    Options options = super.getOptions();

    OptionGroup group = new OptionGroup();
    group.setRequired(true);
    group.addOption(OptionBuilder.withLongOpt("problem").hasArg().withArgName("name")
            .withDescription("Problem name").create('b'));
    group.addOption(OptionBuilder.withLongOpt("dimension").hasArg().withArgName("number")
            .withDescription("Number of objectives").create('d'));
    options.addOptionGroup(group);

    options.addOption(OptionBuilder.withLongOpt("epsilon").hasArg().withArgName("e1,e2,...")
            .withDescription("Epsilon values for epsilon-dominance").create('e'));
    options.addOption(OptionBuilder.withLongOpt("output").hasArg().withArgName("file")
            .withDescription("Output file containing the merged set").isRequired().create('o'));
    options.addOption(OptionBuilder.withLongOpt("vars").hasArg().withArgName("vars")
            .withDescription("Number of decision variables.").isRequired().create('v'));
    options.addOption(OptionBuilder.withLongOpt("resultFile")
            .withDescription("Output result file instead of reference set").create('r'));

    return options;
}

From source file:net.ninjacat.stubborn.Stubborn.java

@SuppressWarnings("AccessStaticViaInstance")
private static Options createOptions() {
    Option source = OptionBuilder.withArgName("path|jar").withLongOpt(Context.SOURCE).hasArgs().isRequired()
            .withDescription(// w w  w. jav a  2s  .  c  om
                    "Source path. Might be folder on a file system or a jar-file. You can specify multiple sources")
            .create('s');
    Option output = OptionBuilder.withArgName("path|jar").withLongOpt(Context.OUTPUT).hasArg().isRequired()
            .withDescription("Folder for output. Transformed classes will be stored to this folder")
            .create('o');
    Option rules = OptionBuilder.withArgName("xml-file").withLongOpt(Context.TRANSFORM_RULES).hasArg()
            .withDescription(
                    "Transformation rules file. If not specified, then default-rules.xml in current directory will be used")
            .create('r');
    Option stripNonPublic = OptionBuilder.withLongOpt(Context.STRIP_NON_PUBLIC)
            .withDescription("Only stub public methods, non-public methods will be removed from output classes")
            .create('n');
    Option stripFields = OptionBuilder.withLongOpt(Context.STRIP_FIELDS)
            .withDescription("Remove field definitions from classes").create('m');
    Option stripFinals = OptionBuilder.withLongOpt(Context.STRIP_FINAL)
            .withDescription("Remove final modifier from methods and classes").create('f');
    Option generateInstances = OptionBuilder.withLongOpt(Context.GENERATE_INSTANCES)
            .withDescription("Generate return newInstance() for reference return types").create("g");
    Option targetVersion = OptionBuilder.withArgName("version").withLongOpt(Context.TARGET_VERSION)
            .withDescription("Generate class files with specified target Java version").hasOptionalArg()
            .withType(Integer.class).create('t');
    Option verbose = OptionBuilder.withArgName("level").withLongOpt(Context.VERBOSE)
            .withDescription("Provide more output (-v 2 for even more output)").hasOptionalArg()
            .withType(Integer.class).create('v');
    Option ignoreDupMatchers = OptionBuilder.withLongOpt(Context.IGNORE_DUPLICATE_MATCHERS)
            .withDescription("Ignore duplicate matchers, use first defined.").create('i');
    Option classPath = OptionBuilder.withLongOpt(Context.CLASSPATH).hasArg()
            .withDescription("Additional classpath to be used during transformation").create("c");
    Option help = new Option("h", "help", false, "Show this help message");

    Options options = new Options();
    options.addOption(source);
    options.addOption(output);
    options.addOption(rules);
    options.addOption(stripNonPublic);
    options.addOption(stripFields);
    options.addOption(stripFinals);
    options.addOption(generateInstances);
    options.addOption(verbose);
    options.addOption(ignoreDupMatchers);
    options.addOption(classPath);
    options.addOption(help);
    options.addOption(targetVersion);

    return options;
}

From source file:de.tudarmstadt.ukp.teaching.uima.nounDecompounding.ranking.AbstractRanker.java

@SuppressWarnings("static-access")
protected static Options basicOptions() {
    // Set up options
    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt(INDEX_OPTION)
            .withDescription("The path to the web1t lucene index").hasArg().isRequired().create());
    options.addOption(OptionBuilder.withLongOpt(LIMIT_OPTION)
            .withDescription("(optional) Limit of results to evaluate").hasArg().create());

    return options;
}

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

/**
 * //from  w  w w.j a va2s .co  m
 */
@SuppressWarnings("static-access")
public NgramProbs(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("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' with one ngram per line. 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");

    } 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.rapplogic.aru.uploader.CliOptions.java

private void addSharedOptions() {
    optionList.add(OptionBuilder.withLongOpt(sketch).hasArg().isRequired(true)
            .withDescription("Path to compiled sketch (compiled by Arduino IDE). Required").create("s"));

    // following are optional

    defaults.put(ackTimeoutMillisArg, "5000");

    optionList.add(OptionBuilder.withLongOpt(ackTimeoutMillisArg).hasArg().withType(Number.class)
            .isRequired(false)//  ww  w. j a va2  s  . c o m
            .withDescription(
                    "How long to wait for ACK from Arduino before retrying (in milliseconds). Default is "
                            + defaults.get(ackTimeoutMillisArg))
            .create("c"));

    defaults.put(arduinoTimeoutArg, "60");

    optionList.add(OptionBuilder.withLongOpt(arduinoTimeoutArg).hasArg().withType(Number.class)
            .isRequired(false)
            .withDescription(
                    "How long Arduino waits between commands before it exits programming mode (in seconds). Default is "
                            + defaults.get(arduinoTimeoutArg)
                            + ". Note: This is not the time that programming must complete in, only the max time between commands")
            .create("a"));

    defaults.put(retriesPerPacketArg, "10");

    optionList.add(
            OptionBuilder.withLongOpt(retriesPerPacketArg).hasArg().withType(Number.class).isRequired(false)
                    .withDescription("How many times a command is retried before giving up. Default is "
                            + defaults.get(retriesPerPacketArg))
                    .create("r"));

    defaults.put(delayBetweenRetriesMillisArg, "250");

    optionList.add(OptionBuilder.withLongOpt(delayBetweenRetriesMillisArg).hasArg().withType(Number.class)
            .isRequired(false)
            .withDescription("Delay before retrying to send a packet (in milliseconds). Default is "
                    + defaults.get(delayBetweenRetriesMillisArg))
            .create("d"));

    optionList.add(OptionBuilder.withLongOpt(verboseArg).isRequired(false).withDescription("Show debug output")
            .create("d"));

    optionList
            .add(OptionBuilder.withLongOpt("help").isRequired(false).withDescription("Show help").create("h"));
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.sensitivity.ResultFileSeedMerger.java

@SuppressWarnings("static-access")
@Override// w w w .ja  va2 s.  c  om
public Options getOptions() {
    Options options = super.getOptions();

    OptionGroup group = new OptionGroup();
    group.setRequired(true);
    group.addOption(OptionBuilder.withLongOpt("problem").hasArg().withArgName("name").create('b'));
    group.addOption(OptionBuilder.withLongOpt("dimension").hasArg().withArgName("number").create('d'));
    options.addOptionGroup(group);

    options.addOption(
            OptionBuilder.withLongOpt("output").hasArg().withArgName("file").isRequired().create('o'));
    options.addOption(OptionBuilder.withLongOpt("epsilon").hasArg().withArgName("e1,e2,...").create('e'));

    return options;
}