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:com.anjlab.sat3.Program.java

@SuppressWarnings("static-access")
private static Options getCommandLineOptions() {
    Options options = new Options();

    options.addOption(/*w w  w  . ja va  2  s  .co m*/
            OptionBuilder.withLongOpt("help").withDescription("Prints this help message.").create(HELP_OPTION));

    options.addOption(OptionBuilder.withLongOpt("use-pretty-print")
            .withDescription("If specified, program will print detailed information about "
                    + "formulas including triplet values."
                    + "\nUseful when studying how algorithm works (especially if variables count less than 20)."
                    + "\nDisabled by default.")
            .create(USE_PRETTY_PRINT_OPTION));

    options.addOption(OptionBuilder.withLongOpt("disable-assertions")
            .withDescription(
                    "Disables internal program self-check during execution. This may improve performance.")
            .create(DISABLE_ASSERTIONS_OPTION));

    options.addOption(OptionBuilder.withLongOpt("use-abc-var-names")
            .withDescription("If specified, program will use ABC names for variables "
                    + "(like 'a', 'b', ..., 'z' instead of 'x1', 'x2', etc.) during formula output."
                    + "\nDisabled by default. Forced disabled if variables count more than 26.")
            .create(USE_ABC_VAR_NAMES_OPTION));

    options.addOption(OptionBuilder.withLongOpt("hss-image-output").hasArg().withArgName("filename")
            .withDescription(
                    "File name where visual representation of resulting basic graph will be written (only for SAT instances). Defaults to <input-file-name>-hss-0.png")
            .create(HSS_IMAGE_OUTPUT_FILENAME_OPTION));

    options.addOption(OptionBuilder.withLongOpt("output").hasArg().withArgName("filename").withDescription(
            "File name where results of calculation will be written (time measurements and satisfying set for SAT instances). Defaults to <input-file-name>-results.txt")
            .create(RESULTS_OUTPUT_FILE_OPTION));

    options.addOption(OptionBuilder.withLongOpt("evaluate-formula").hasArg().withArgName("filename")
            .withDescription("Evaluate formula using variable values from this file.").create(EVALUATE_OPTION));

    options.addOption(OptionBuilder.withLongOpt("create-skt")
            .withDescription("Convert input formula to Romanov SKT file format.").create(CREATE_SKT_OPTION));

    options.addOption(OptionBuilder.withLongOpt("find-hss-route").hasArg().withArgName("dirname")
            .withDescription("Find route in HSS from folder <dirname>").create(FIND_HSS_ROUTE_OPTION));

    options.addOption(OptionBuilder.withLongOpt("generate-3sat-formula")
            .withDescription(
                    "Generate 3-SAT formula from <input-file-name> and save it to <input-file-name>-3sat.cnf.")
            .create(GENERATE_3SAT_OPTION));

    return options;
}

From source file:com.aerospike.examples.timeseries.TimeSeriesManipulator.java

public static void main(String[] args) throws ParseException, FileNotFoundException, IOException,
        org.apache.commons.cli.ParseException, InterruptedException {
    try {/*  w  ww  . jav  a  2 s.co  m*/
        Options options = new Options();
        options.addOption("h", "host", true, "Server hostname (default: localhost)");
        options.addOption("p", "port", true, "Server port (default: 3000)");
        options.addOption("t", "ticker", true, "Ticker (default: AAPL,IBM,ORCL,MSFT,CSCO)");
        options.addOption("o", "op", true, "Load or Read Data (default: R)");
        options.addOption("s", "start", true, "Start Date for Query (format: dd/MM/yyyy)");
        options.addOption("e", "end", true, "End Date for Query (for,at: dd/MM/yyyy)");
        options.addOption("d", "days", true, "Number of Days (default: from the stocktick.txt file)");

        options.addOption(OptionBuilder.withLongOpt("help").create('l'));

        String header = "Options\n\n";
        //String footer = "\nPlease report issues aveekshith@aerospike.com";

        HelpFormatter formatter = new HelpFormatter();

        CommandLineParser parser = new PosixParser();
        CommandLine cl = parser.parse(options, args, false);

        String host = cl.getOptionValue("h", "127.0.0.1");
        String portString = cl.getOptionValue("p", "3000");
        String tickerList = cl.getOptionValue("t", "AAPL,IBM,ORCL,MSFT,CSCO");
        String operation = cl.getOptionValue("o", "R");

        String days = cl.getOptionValue("d");
        DateOperator dateOperator = new DateOperator();
        String prevDate, currentDate;
        if (days != null)
            prevDate = dateOperator.getPrevDate(days);
        else
            prevDate = dateOperator.getPrevDate("100");
        currentDate = dateOperator.getCurrentDate();
        String startDate = cl.getOptionValue("s", prevDate);
        String endDate = cl.getOptionValue("e", currentDate);
        if (cl.hasOption("l")) {
            formatter.printHelp("java -jar target/AeroTimeSeries-1.0.jar", header, options, null, true);
            System.exit(0);
        } else {
            int port = Integer.parseInt(portString);
            TimeSeriesManipulator ts = new TimeSeriesManipulator(host, port, tickerList, startDate, endDate,
                    operation, days);
            ts.run();
        }
    } catch (Exception ex) {
        System.out.println("Exception: " + ex.toString());
        ex.printStackTrace();
    }

}

From source file:ca.uqac.info.trace.execution.BabelTrace.java

/**
 * Sets up the options for the command line parser
 * @return The options/*from w w  w  .  j a  v a  2s. c  om*/
 */
@SuppressWarnings("static-access")
private static Options setupOptions() {
    Options options = new Options();
    Option opt;
    opt = OptionBuilder.withLongOpt("run")
            .withDescription("Run the selected tool after conversion (default: no)").create("r");
    options.addOption(opt);
    opt = OptionBuilder.withLongOpt("help").withDescription("Display command line usage").create("h");
    options.addOption(opt);
    opt = OptionBuilder.withLongOpt("batch")
            .withDescription("Don't run the tool, but output the command line that would be used").create("b");
    options.addOption(opt);
    opt = OptionBuilder.withLongOpt("trace").withArgName("filename").hasArg()
            .withDescription("Read trace from filename").create("t");
    options.addOption(opt);
    opt = OptionBuilder.withLongOpt("formula").withArgName("filename").hasArg()
            .withDescription("Read formula from filename").create("f");
    options.addOption(opt);
    opt = OptionBuilder.withLongOpt("convert").withArgName("toolname").hasArg()
            .withDescription("Convert to format of toolname").create("c");
    options.addOption(opt);
    opt = OptionBuilder.withLongOpt("version").withDescription("Show version of BabelTrace").create();
    options.addOption(opt);
    opt = OptionBuilder.withLongOpt("input-type").withArgName("type").hasArg()
            .withDescription("Trace input type").create("i");
    options.addOption(opt);
    opt = OptionBuilder.withLongOpt("output-dir").withArgName("dir").hasArg()
            .withDescription("Write output files to dir").create("o");
    options.addOption(opt);

    return options;
}

From source file:com.flaptor.indextank.api.EmbeddedIndexEngine.java

@SuppressWarnings("static-access")
private static Options getOptions() {
    Option baseDir = OptionBuilder.withArgName("base-dir").hasArg().isRequired()
            .withDescription("The basint e dir").withLongOpt("dir").create("d");

    Option basePort = OptionBuilder.withArgName("base-port").hasArg().withDescription("The base port")
            .withLongOpt("port").create("p");

    Option boostSize = OptionBuilder.withArgName("boosts-size").hasArg()
            .withDescription("Number of available boosts").withLongOpt("boosts").create("b");

    Option rtiSize = OptionBuilder.withArgName("rti-size").hasArg()
            .withDescription("The size limit for the RTI").withLongOpt("rti-size").create("rs");

    Option help = OptionBuilder.withDescription("displays this help").withLongOpt("help").create("h");

    Option snippets = OptionBuilder.withDescription("Allow snippet generation and field fetching.")
            .withLongOpt("snippets").create("sn");

    Option recover = OptionBuilder.withDescription("Recover documents from the storage.").withLongOpt("recover")
            .create("r");

    Option indexCode = OptionBuilder.withArgName("code").hasArg().isRequired()
            .withDescription("the index code this indexengine has").withLongOpt("index-code").create("ic");

    Option environment = OptionBuilder.withArgName("environment").hasArg().isRequired()
            .withDescription("environment prefix").withLongOpt("environment-prefix").create("env");
    /*//from www  . j a  v  a2s. co  m
     * Analyzer argument should receive a JSON string with the following root structure:
     *    - factory: a java type that implements the following static method: org.apache.lucene.analysis.Analyzer buildAnalyzer(Map).
     *    - configuration: a JSON object to be passed to the buildAnalyzer method. 
     */
    Option analyzer = OptionBuilder.withArgName("analyzer").hasArg().withDescription("specific analyzer")
            .withLongOpt("analyzer").create("an");

    Option configFile = OptionBuilder.withArgName("conf-file").hasArg().withDescription("configuration file")
            .withLongOpt("conf-file").create("cf");

    Option loadState = OptionBuilder.withArgName("load")
            .withDescription(
                    "if present, the index engine will try to restore its state" + "from the serialized form.")
            .withLongOpt("load-state").create("l");

    Option suggest = OptionBuilder.withArgName("suggest").hasArg()
            .withDescription("if present, loads the suggest/autocomplete system.").withLongOpt("suggest")
            .create("su");
    Option facets = OptionBuilder.withArgName("facets")
            .withDescription("if present, performs facetings queries.").withLongOpt("facets").create("fa");

    Option functions = OptionBuilder.withArgName("functions").hasArg()
            .withDescription(
                    "list of '|' separated scoring functions, each of which has the form <id>:<definition>.")
            .withLongOpt("functions").create("fn");
    Option didyoumean = OptionBuilder.withLongOpt("didyoumean").withDescription(
            "if present, performs 'did you mean?' suggestions on queries. Requires --suggest documents.")
            .create("dym");

    Option storage = OptionBuilder.withLongOpt("storage").hasArg()
            .withDescription(
                    "if present, specifies a storage backend. Options are 'bdb' and 'ram'. Defaults to 'ram'.")
            .create("st");

    Option bdbCache = OptionBuilder.withLongOpt("bdb-cache").hasArg().withDescription(
            "if present, specifies the size of the berkeleyDb cache per thread, in megabytes. Defaults to 100MB.")
            .create("bc");

    Options options = new Options();
    options.addOption(baseDir);
    options.addOption(basePort);
    options.addOption(boostSize);
    options.addOption(help);
    options.addOption(snippets);
    options.addOption(recover);
    options.addOption(indexCode);
    options.addOption(rtiSize);
    options.addOption(loadState);
    options.addOption(suggest);
    options.addOption(facets);
    options.addOption(functions);
    options.addOption(environment);
    options.addOption(analyzer);
    options.addOption(didyoumean);
    options.addOption(configFile);
    options.addOption(storage);
    options.addOption(bdbCache);

    return options;
}

From source file:com.jagornet.dhcp.server.JagornetDhcpServer.java

/**
 * Setup command line options.//from ww w . j  av a  2 s  .  c  o  m
 */
@SuppressWarnings("static-access")
private void setupOptions() {
    Option configFileOption = OptionBuilder.withLongOpt("configfile").withArgName("filename")
            .withDescription("Configuration file (default = " + DEFAULT_CONFIG_FILENAME + ").").hasArg()
            .create("c");
    options.addOption(configFileOption);

    Option portOption = OptionBuilder.withLongOpt("v6port").withArgName("portnum")
            .withDescription("DHCPv6 Port number (default = 547).").hasArg().create("6p");
    options.addOption(portOption);

    Option mcastOption = OptionBuilder.withLongOpt("v6mcast").withArgName("interfaces")
            .withDescription("DHCPv6 Multicast support (default = none). "
                    + "Use this option without arguments to instruct the server to bind to all "
                    + "multicast-enabled IPv6 interfaces on the host. Optionally, use arguments "
                    + "to list specific interfaces, separated by spaces.")
            .hasOptionalArgs().create("6m");
    options.addOption(mcastOption);

    Option ucastOption = OptionBuilder.withLongOpt("v6ucast").withArgName("addresses")
            .withDescription("DHCPv6 Unicast addresses (default = all IPv6 addresses). "
                    + "Use this option to instruct the server to bind to a specific list "
                    + "of global IPv6 addresses, separated by spaces. These addresses "
                    + "should be configured on one or more DHCPv6 relay agents connected "
                    + "to DHCPv6 client links.")
            .hasOptionalArgs().create("6u");
    options.addOption(ucastOption);

    Option v4BcastOption = OptionBuilder.withLongOpt("v4bcast").withArgName("interface")
            .withDescription("DHCPv4 broadcast support (default = none). "
                    + "Use this option to specify the interface for the server to "
                    + "receive and send broadcast DHCPv4 packets. Only one interface "
                    + "may be specified. All other interfaces on the host will only "
                    + "receive and send unicast traffic.  The default IPv4 address on "
                    + "the specified interface will be used for determining the "
                    + "DHCPv4 client link within the server configuration file.")
            .hasArg().create("4b");
    options.addOption(v4BcastOption);

    Option v4UcastOption = OptionBuilder.withLongOpt("v4ucast").withArgName("addresses")
            .withDescription("DHCPv4 Unicast addresses (default = all IPv4 addresses). "
                    + "Use this option to instruct the server to bind to a specific list "
                    + "of IPv4 addresses, separated by spaces. These addresses "
                    + "should be configured on one or more DHCPv4 relay agents connected "
                    + "to DHCPv4 client links.")
            .hasOptionalArgs().create("4u");
    options.addOption(v4UcastOption);

    Option v4PortOption = OptionBuilder.withLongOpt("v4port").withArgName("portnum")
            .withDescription("DHCPv4 Port number (default = 67).").hasArg().create("4p");
    options.addOption(v4PortOption);

    Option testConfigFileOption = OptionBuilder.withLongOpt("test-configfile").withArgName("filename")
            .withDescription("Test configuration file, then exit.").hasArg().create("tc");
    options.addOption(testConfigFileOption);

    Option listIfOption = new Option("li", "list-interfaces", false,
            "Show detailed host interface list, then exit.");
    options.addOption(listIfOption);

    Option versionOption = new Option("v", "version", false, "Show version information, then exit.");
    options.addOption(versionOption);

    Option helpOption = new Option("?", "help", false, "Show this help page.");
    options.addOption(helpOption);
}

From source file:com.aliyun.odps.ship.common.OptionsBuilder.java

public static Options getGlobalOptions() {

    Options opts = new Options();

    opts.addOption(OptionBuilder.withLongOpt(Constants.CHARSET)
            .withDescription("specify file charset, default " + Constants.IGNORE_CHARSET + ". set "
                    + Constants.IGNORE_CHARSET + " to download raw data")
            .hasArg().withArgName("ARG").create("c"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.FIELD_DELIMITER)
            .withDescription("specify field delimiter, default "
                    + Util.toHumanReadableString(Constants.DEFAULT_FIELD_DELIMITER))
            .hasArg().withArgName("ARG").create("fd"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.RECORD_DELIMITER)
            .withDescription("specify record delimiter, default "
                    + Util.toHumanReadableString(Constants.DEFAULT_RECORD_DELIMITER))
            .hasArg().withArgName("ARG").create("rd"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.DATE_FORMAT_PATTERN)
            .withDescription("specify date format pattern, default " + Constants.DEFAULT_DATE_FORMAT_PATTERN)
            .hasArg().withArgName("ARG").create("dfp"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.NULL_INDICATOR)
            .withDescription("specify null indicator string, default "
                    + Util.toHumanReadableString(Constants.DEFAULT_NULL_INDICATOR))
            .hasArg().withArgName("ARG").create("ni"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.TIME_ZONE)
            .withDescription(/*from w  w  w  .  jav a  2s.c o  m*/
                    "time zone, default local timezone: " + Calendar.getInstance().getTimeZone().getID())
            .hasArg().withArgName("ARG").create("tz"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.COMPRESS).withDescription("compress, default true")
            .hasArg().withArgName("ARG").create("cp"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.HEADER)
            .withDescription("if local file should have table header, default " + Constants.DEFAULT_HEADER)
            .hasArg().withArgName("ARG").create("h"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.SESSION_DIR)
            .withDescription("set session dir, default " + Constants.DEFAULT_SESSION_DIR).hasArg()
            .withArgName("ARG").create("sd"));
    opts.addOption(OptionBuilder.withLongOpt(Constants.THREADS)
            .withDescription("number of threads, default " + Constants.DEFAULT_THREADS).hasArg()
            .withArgName("ARG").create());
    return opts;
}

From source file:com.facebook.presto.accumulo.tools.PaginationTask.java

@SuppressWarnings("static-access")
@Override/*from  ww  w.j  a  v a2 s . c om*/
public Options getOptions() {
    Options opts = new Options();
    opts.addOption(OptionBuilder.withLongOpt("host").withDescription("Presto server host name").hasArg()
            .isRequired().create(HOST_OPT));
    opts.addOption(OptionBuilder.withLongOpt("port").withDescription("Presto server port").hasArg().isRequired()
            .create(PORT_OPT));
    opts.addOption(OptionBuilder.withLongOpt("file").withDescription("File containing SQL query to execute")
            .hasArg().isRequired().create(QUERY_FILE_OPT));
    opts.addOption(OptionBuilder.withLongOpt("columns")
            .withDescription("Columns returned from the SQL SELECT, in order").hasArgs().isRequired()
            .create(COLUMNS_OPT));
    opts.addOption(OptionBuilder.withLongOpt("size").withDescription("Page size.  Default 20 rows per page")
            .hasArg().create(PAGE_SIZE_OPT));
    return opts;
}

From source file:net.palette_software.pet.restart.CliControl.java

static void createCommandLineOptions(Options options) {
    options.addOption("h", "help", false, "This help.");
    options.addOption("v", "version", false, "Print version information.");
    options.addOption("a", "restart", false, "Restart all processes one-by-one.");
    options.addOption("rv", "restart-vizql", false, "Restart VizQL workers.");
    options.addOption("rc", "restart-cache", false, "Restart Cache Server.");
    options.addOption("s", "simulation", false, "Simulate all the restarts.");
    options.addOption("i", "install", false, "Enable Balancer-manager.");
    options.addOption("rb", "restart-backgrounder", false, "Restart Backgrounder workers.");
    options.addOption("rp", "restart-vizportal", false, "Restart Vizportal workers.");
    options.addOption("rd", "restart-dataserver", false, "Restart Data Server workers.");
    options.addOption("pg", "reload-postgres", false, "Send reload signal to repository.");
    options.addOption("ra", "reload-apache", false, "Reload gateway rules.");
    options.addOption("f", "force", false, "Disable JMX, send signals immediately (non-graceful).");

    options.addOption(OptionBuilder.withLongOpt("jmx-polling-time").withDescription("JMX data polling time")
            .hasArg().withArgName("SECONDS").create());

    options.addOption(OptionBuilder.withLongOpt("wait").withDescription("Waiting time between jobs").hasArg()
            .withArgName("SECONDS").create());

    options.addOption(OptionBuilder.withLongOpt("wait-errors")
            .withDescription("Waiting time after errors/retries").hasArg().withArgName("SECONDS").create());

    options.addOption(OptionBuilder.withLongOpt("force-restart-timeout")
            .withDescription("Force restart timeout").hasArg().withArgName("SECONDS").create());

    options.addOption(OptionBuilder.withLongOpt("tabsvc-config-dir").withDescription("Path to tabsvc configs")
            .hasArg().withArgName("PATH").create());
    options.addOption(OptionBuilder.withLongOpt("tableau-installation-dir")
            .withDescription("Path to Tableau Server installation directory").hasArg().withArgName("PATH")
            .create());/*from  www.  j a v  a2s.  co m*/

}

From source file:be.ugent.intec.halvade.HalvadeOptions.java

protected void createOptions() {
    Option optIn = OptionBuilder.withArgName("input").hasArg().isRequired(true)
            .withDescription("Input directory on hdfs containing fastq files.").create("I");
    Option optOut = OptionBuilder.withArgName("output").hasArg().isRequired(true)
            .withDescription("Output directory on hdfs.").create("O");
    Option optBin = OptionBuilder.withArgName("bin.tar.gz").hasArg().isRequired(true)
            .withDescription("The tarred file containing all binary files located on HDFS.").create("B");
    Option optRef = OptionBuilder.withArgName("reference").hasArg().isRequired(true).withDescription(
            "Name of the fasta file name of the reference (without extension) on HDFS. Make sure the BWA index has the same prefix.")
            .create("R");
    Option optNodes = OptionBuilder.withArgName("nodes").hasArg().isRequired(true)
            .withDescription("Sets the number of nodes in this cluster.").withLongOpt("nodes").create("N");
    Option optVcores = OptionBuilder.withArgName("cores").hasArg().isRequired(true)
            .withDescription("Sets the available cpu cores per node in this cluster.").withLongOpt("vcores")
            .create("C");
    Option optMem = OptionBuilder.withArgName("gb").hasArg().isRequired(true)
            .withDescription("Sets the available memory [in GB] per node in this cluster.").withLongOpt("mem")
            .create("M");
    Option optMmem = OptionBuilder.withArgName("gb").hasArg()
            .withDescription("Overrides the maximum map container memory [in GB].").withLongOpt("mapmem")
            .create();/*from   w  w  w .j  a va  2  s .c o  m*/
    Option optRmem = OptionBuilder.withArgName("gb").hasArg()
            .withDescription("Overrides the maximum reduce container memory [in GB].").withLongOpt("redmem")
            .create();
    Option optSites = OptionBuilder.withArgName("snpDBa,snpDBb").hasArg().isRequired(true)
            .withDescription("Name of snpDB files for the genome on HDFS. If multiple separate with \',\'.")
            .create("D");
    Option optStarGenome = OptionBuilder.withArgName("stargenome").hasArg()
            .withDescription("Directory on HDFS containing all STAR genome files").withLongOpt("star")
            .create("S");
    Option optTmp = OptionBuilder.withArgName("dir").hasArg()
            .withDescription("Sets the location for temporary files on every node [/tmp/halvade/].")
            .withLongOpt("tmp").create();
    Option optrefdir = OptionBuilder.withArgName("dir").hasArg().withDescription(
            "Sets the folder containing all the reference files for BWA or STAR and GATK on every node [tmp directory].")
            .withLongOpt("refdir").create();
    Option optJava = OptionBuilder.withArgName("java").hasArg()
            .withDescription("Set location of java binary to use [must be 1.7+].").create("J");
    // "ID:" + RGID + " LB:" + RGLB + " PL:" + RGPL + " PU:" + RGPU + " SM:" + RGSM
    Option optID = OptionBuilder.withArgName("RGID").hasArg()
            .withDescription("sets the RGID for the read-group.").withLongOpt("id").create();
    Option optLB = OptionBuilder.withArgName("RGLB").hasArg()
            .withDescription("sets the RGLB for the read-group.").withLongOpt("lb").create();
    Option optPL = OptionBuilder.withArgName("RGPL").hasArg()
            .withDescription("sets the RGPL for the read-group.").withLongOpt("pl").create();
    Option optPU = OptionBuilder.withArgName("RGPU").hasArg()
            .withDescription("sets the RGPU for the read-group.").withLongOpt("pu").create();
    Option optSM = OptionBuilder.withArgName("RGSM").hasArg()
            .withDescription("sets the RGSM for the read-group.").withLongOpt("sm").create();
    Option optCov = OptionBuilder.withArgName("coverage").hasArg()
            .withDescription("Sets the coverage to better distribute the tasks.").withLongOpt("cov").create();
    Option optScc = OptionBuilder.withArgName("scc").hasArg()
            .withDescription("Sets stand_call_conf for gatk Variant Caller.").withLongOpt("scc").create();
    Option optSec = OptionBuilder.withArgName("sec").hasArg()
            .withDescription("Sets stand_emit_conf for gatk Variant Caller.").withLongOpt("sec").create();
    Option optBed = OptionBuilder.withArgName("bedfile").hasArg()
            .withDescription("Sets the bed file containing relevant (Genes) regions which "
                    + "will be used to split the genome into genomic regions.")
            .withLongOpt("bed").create();
    Option optFilterBed = OptionBuilder.withArgName("bedfile").hasArg()
            .withDescription("Sets the bed file containing relevant (Exome) regions which "
                    + " will be used to filter in the GATK steps.")
            .withLongOpt("fbed").create();
    Option optGff = OptionBuilder.withArgName("gff").hasArg().withDescription(
            "Sets the gff file to be used with FeautreCounts. This is required to count reads per exon.")
            .withLongOpt("gff").create();
    Option optstargtf = OptionBuilder.withArgName("gtf").hasArg()
            .withDescription("Sets the gtf file to be used within the STAR alignment.").withLongOpt("stargtf")
            .create();
    Option optMpn = OptionBuilder.withArgName("tasks").hasArg()
            .withDescription("Overrides the number of map tasks running simultaneously on each node. ")
            .withLongOpt("mpn").create();
    Option optRpn = OptionBuilder.withArgName("tasks").hasArg()
            .withDescription("Overrides the number of reduce tasks running simultaneously on each node. ")
            .withLongOpt("rpn").create();
    Option optCustomArgs = OptionBuilder.withLongOpt("custom_args").withArgName("tool=args").hasArgs(2)
            .withValueSeparator()
            .withDescription(
                    "Adds custom arguments for a tool. If a module in a tool is used, add the name after an underscore. "
                            + "Possible values: " + getProgramNames())
            .withLongOpt("CA").create();
    Option optVerbose = OptionBuilder.withArgName("num").hasArg()
            .withDescription("Sets verbosity of debugging [2].").create("v");
    Option optAln = OptionBuilder.withArgName("num").hasArg().withDescription(
            "Sets the aligner used in Halvade. Possible values are 0 (bwa aln+sampe)[default], 1 (bwa mem), 2 (bowtie2), 3 (cushaw2).")
            .withLongOpt("aln").create();
    Option optReadsPerRegion = OptionBuilder.withArgName("file").hasArg().withDescription(
            "Give a file with read counts per region to better distribute the regions (split by readcount [default] or reorder regions by size [-reorder_regions]).")
            .withLongOpt("rpr").create();

    //flags
    Option optSingle = OptionBuilder
            .withDescription("Sets the input files to single reads [default is paired-end reads].")
            .withLongOpt("single").create();
    Option optCombine = OptionBuilder
            .withDescription("Just Combines the vcf on HDFS [out dir] and doesn't run the hadoop job.")
            .withLongOpt("combine").create();
    Option optPp = OptionBuilder
            .withDescription(
                    "Uses elPrep to preprocess the data for GATK, this requires more memory but is faster.")
            .withLongOpt("elprep").create();
    Option optFilterDBsnp = OptionBuilder
            .withDescription("Use Bedtools to select the needed interval of dbsnp.").withLongOpt("filter_dbsnp")
            .create();
    Option optJustAlign = OptionBuilder.withDescription("Only align the reads.").withLongOpt("justalign")
            .create("A");
    Option optSmt = OptionBuilder.withDescription("Enable simultaneous multithreading.").withLongOpt("smt")
            .create();
    Option optKeep = OptionBuilder.withDescription("Keep intermediate files.").withLongOpt("keep").create();
    Option optHap = OptionBuilder
            .withDescription("Use HaplotypeCaller instead of UnifiedGenotyper for Variant Detection.")
            .withLongOpt("haplotypecaller").create("H");
    Option optRna = OptionBuilder.withDescription(
            "Run the RNA Best Practices pipeline by Broad [default is DNA pipeline]. SG needs to be set for this.")
            .withLongOpt("rna").create();
    Option optDry = OptionBuilder.withDescription(
            "Execute a dryrun, will calculate task size, split for regions etc, but not execute the MapReduce job.")
            .withLongOpt("dryrun").create();
    Option optDrop = OptionBuilder
            .withDescription("Drop all paired-end reads where the pairs are aligned to different chromosomes.")
            .withLongOpt("drop").create();
    Option optReportAll = OptionBuilder
            .withDescription("Reports all variants at the same location when combining variants.")
            .withLongOpt("report_all").create();
    Option optBamIn = OptionBuilder
            .withDescription("Uses aligned bam as input files instead of unaligned fastq files.")
            .withLongOpt("bam").create();
    Option optRedis = OptionBuilder.withDescription(
            "This will enable Halvade to redistribute resources when possible when not all containers are used.")
            .withLongOpt("redistribute").create();
    Option optMergeBam = OptionBuilder.withDescription(
            "Merges all bam output from either bam input or the aligned reads from the fastq input files.")
            .withLongOpt("merge_bam").create();
    Option optReorderRegions = OptionBuilder.withDescription(
            "Use the default split way but reorder tasks by size based on the read count file given by -rpr option.")
            .withLongOpt("reorder_regions").create();
    Option optupdateRG = OptionBuilder
            .withDescription("Update the readgroup when reading from a BAM input file.")
            .withLongOpt("update_rg").create();
    Option optCount = OptionBuilder
            .withDescription("Count the number of reads per reduce task (for debug purposes).")
            .withLongOpt("count").create();
    Option optRemDup = OptionBuilder.withDescription("Remove PCR duplicates for GATK.")
            .withLongOpt("remove_dups").create();
    Option optFixEnc = OptionBuilder
            .withDescription(
                    "Fix the quality encoding of old (pre 1.8) Illumina fastq files to the new encoding.")
            .withLongOpt("illumina").create();

    options.addOption(optIn);
    options.addOption(optOut);
    options.addOption(optRef);
    options.addOption(optSites);
    options.addOption(optBin);
    options.addOption(optTmp);
    options.addOption(optrefdir);
    options.addOption(optSingle);
    options.addOption(optAln);
    options.addOption(optID);
    options.addOption(optLB);
    options.addOption(optPL);
    options.addOption(optPU);
    options.addOption(optSM);
    options.addOption(optPp);
    options.addOption(optFilterDBsnp);
    options.addOption(optHap);
    options.addOption(optScc);
    options.addOption(optSec);
    options.addOption(optBed);
    options.addOption(optFilterBed);
    options.addOption(optJava);
    options.addOption(optCombine);
    options.addOption(optNodes);
    options.addOption(optVcores);
    options.addOption(optMem);
    options.addOption(optKeep);
    options.addOption(optJustAlign);
    //        options.addOption(optCov);
    options.addOption(optMpn);
    options.addOption(optGff);
    options.addOption(optRpn);
    options.addOption(optDry);
    options.addOption(optDrop);
    options.addOption(optReportAll);
    options.addOption(optSmt);
    options.addOption(optRna);
    //        options.addOption(optReadsPerRegion);
    options.addOption(optStarGenome);
    options.addOption(optBamIn);
    options.addOption(optCustomArgs);
    options.addOption(optRedis);
    options.addOption(optRmem);
    options.addOption(optMmem);
    options.addOption(optMergeBam);
    options.addOption(optVerbose);
    //        options.addOption(optReorderRegions);
    options.addOption(optupdateRG);
    options.addOption(optCount);
    options.addOption(optRemDup);
    options.addOption(optstargtf);
    options.addOption(optFixEnc);
}

From source file:com.upload.DcmSnd.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*from  w  ww  . j  a v a  2 s .c o m*/
    OptionBuilder.withDescription("set device name, use DCMSND by default");
    opts.addOption(OptionBuilder.create("device"));

    OptionBuilder.withArgName("aet[@host][:port]");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set AET, local address and listening port of local "
            + "Application Entity, use device name and pick up any valid "
            + "local address to bind the socket by default");
    opts.addOption(OptionBuilder.create("L"));

    opts.addOption("ts1", false,
            "offer Default Transfer Syntax in " + "separate Presentation Context. By default offered with "
                    + "Explicit VR Little Endian TS in one PC.");

    opts.addOption("fileref", false,
            "send objects without pixel data, but with a reference to "
                    + "the DICOM file using DCM4CHE URI Referenced Transfer Syntax "
                    + "to import DICOM objects on a given file system to a DCM4CHEE " + "archive.");

    OptionBuilder.withArgName("username");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "enable User Identity Negotiation with specified username and " + " optional passcode");
    opts.addOption(OptionBuilder.create("username"));

    OptionBuilder.withArgName("passcode");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "optional passcode for User Identity Negotiation, " + "only effective with option -username");
    opts.addOption(OptionBuilder.create("passcode"));

    opts.addOption("uidnegrsp", false,
            "request positive User Identity Negotation response, " + "only effective with option -username");

    OptionBuilder.withArgName("NULL|3DES|AES");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption");
    opts.addOption(OptionBuilder.create("tls"));

    OptionGroup tlsProtocol = new OptionGroup();
    tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections"));
    tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections"));
    tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections"));
    tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections"));
    tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections"));
    opts.addOptionGroup(tlsProtocol);

    opts.addOption("noclientauth", false, "disable client authentification for TLS");

    OptionBuilder.withArgName("file|url");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default");
    opts.addOption(OptionBuilder.create("keystore"));

    OptionBuilder.withArgName("password");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("password for keystore file, 'secret' by default");
    opts.addOption(OptionBuilder.create("keystorepw"));

    OptionBuilder.withArgName("password");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("password for accessing the key in the keystore, keystore password by default");
    opts.addOption(OptionBuilder.create("keypw"));

    OptionBuilder.withArgName("file|url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default");
    opts.addOption(OptionBuilder.create("truststore"));

    OptionBuilder.withArgName("password");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("password for truststore file, 'secret' by default");
    opts.addOption(OptionBuilder.create("truststorepw"));

    OptionBuilder.withArgName("aet@host:port");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("request storage commitment of (successfully) sent objects "
            + "afterwards in new association to specified remote " + "Application Entity");
    opts.addOption(OptionBuilder.create("stgcmtae"));

    opts.addOption("stgcmt", false,
            "request storage commitment of (successfully) sent objects " + "afterwards in same association");

    OptionBuilder.withArgName("attr=value");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription("Replace value of specified attribute "
            + "with specified value in transmitted objects. attr can be "
            + "specified by name or tag value (in hex), e.g. PatientName " + "or 00100010.");
    opts.addOption(OptionBuilder.create("set"));

    OptionBuilder.withArgName("salt");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription(
            "Anonymize the files.  Set to 0 for a random anonymization (not repeatable) or 1 for a daily anonymization or another"
                    + " value for a specific salt for reproducible anonymization (useful for allowing studies to be sent at a later date and still correctly named/associated)");
    OptionBuilder.withLongOpt("anonymize");
    opts.addOption(OptionBuilder.create("a"));

    OptionBuilder.withArgName("sx1[:sx2[:sx3]");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator(':');
    OptionBuilder.withDescription(
            "Suffix SOP [,Series [,Study]] " + "Instance UID with specified value[s] in transmitted objects.");
    opts.addOption(OptionBuilder.create("setuid"));

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximum number of outstanding operations it may invoke "
            + "asynchronously, unlimited by default.");
    opts.addOption(OptionBuilder.create("async"));

    opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, "
            + "pack command and data PDV in one P-DATA-TF PDU by default.");
    opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default");

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default");
    opts.addOption(OptionBuilder.create("connectTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, " + "50ms by default");
    opts.addOption(OptionBuilder.create("soclosedelay"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("delay in ms for closing the listening socket, " + "1000ms by default");
    opts.addOption(OptionBuilder.create("shutdowndelay"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, " + "10s by default");
    opts.addOption(OptionBuilder.create("reaper"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RSP, 10s by default");
    opts.addOption(OptionBuilder.create("rspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default");
    opts.addOption(OptionBuilder.create("acceptTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default");
    opts.addOption(OptionBuilder.create("releaseTO"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default");
    opts.addOption(OptionBuilder.create("rcvpdulen"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default");
    opts.addOption(OptionBuilder.create("sndpdulen"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB");
    opts.addOption(OptionBuilder.create("sorcvbuf"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB");
    opts.addOption(OptionBuilder.create("sosndbuf"));

    OptionBuilder.withArgName("KB");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("transcoder buffer size in KB, 1KB by default");
    opts.addOption(OptionBuilder.create("bufsize"));

    OptionBuilder.withArgName("count");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Batch size - Number of files to be sent in each batch, "
            + "where a storage commit is done between batches ");
    opts.addOption(OptionBuilder.create("batchsize"));

    opts.addOption("lowprior", false, "LOW priority of the C-STORE operation, MEDIUM by default");
    opts.addOption("highprior", false, "HIGH priority of the C-STORE operation, MEDIUM by default");
    opts.addOption("h", "help", false, "print this message");
    opts.addOption("V", "version", false, "print the version information and exit");
    CommandLine cl = null;
    try {
        cl = new GnuParser().parse(opts, args);
    } catch (ParseException e) {
        exit("dcmsnd: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmSnd.class.getPackage();
        System.out.println("dcmsnd v" + p.getImplementationVersion());
        // System.exit(0);
    }
    if (cl.hasOption('h') || cl.getArgList().size() < 2) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
        // System.exit(0);
    }
    return cl;
}