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

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

Introduction

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

Prototype

public static OptionBuilder withDescription(String newDescription) 

Source Link

Document

The next Option created will have the specified description

Usage

From source file:javancss.Javancss.java

/**
 * This is the constructor used in the main routine in
 * javancss.Main./*  w w w  .  j  av a2s.  c o m*/
 * Other constructors might be helpful to use Javancss out
 * of other programs.
 */
public Javancss(String[] args) throws IOException {
    Options options = new Options();
    options.addOption(OptionBuilder.create("help"));
    options.addOption(OptionBuilder.create("version"));
    options.addOption(OptionBuilder.create("debug"));
    options.addOption(OptionBuilder.withDescription("Counts the program NCSS (default).").create("ncss"));
    options.addOption(
            OptionBuilder.withDescription("Assembles a statistic on package level.").create("package"));
    options.addOption(OptionBuilder.withDescription("Counts the object NCSS.").create("object"));
    options.addOption(OptionBuilder.withDescription("Counts the function NCSS.").create("function"));
    options.addOption(OptionBuilder.withDescription("The same as '-function -object -package'.").create("all"));
    options.addOption(OptionBuilder
            .withDescription("Opens a GUI to present the '-all' output in tabbed panels.").create("gui"));
    options.addOption(OptionBuilder.withDescription("Output in XML format.").create("xml"));
    options.addOption(OptionBuilder.withDescription("Output file name. By default output goes to standard out.")
            .create("out"));
    options.addOption(OptionBuilder.withDescription("Recurse to subdirs.").create("recursive"));
    options.addOption(OptionBuilder
            .withDescription("Encoding used while reading source files (default: platform encoding).").hasArg()
            .create("encoding"));

    CommandLine cl;

    try {
        cl = new DefaultParser().parse(options, args);
    } catch (ParseException e) {
        System.err.println("javancss: " + e.getMessage());
        System.err.println("Try `javancss -help' for more information.");
        return;
    }

    if (cl.hasOption("help")) {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("javancss [options] @srcfiles.txt | *.java | <directory> | <stdin>", options);

        return;
    }

    if (cl.hasOption("version")) {
        System.out.println(
                "JavaNCSS " + getClass().getPackage().getSpecificationVersion() + " by Chr. Clemens Lee & co");
        return;
    }

    if (cl.hasOption("debug")) {
        log.setLevel(Level.FINE);
    }

    setEncoding(cl.getOptionValue("encoding"));
    setXML(cl.hasOption("xml"));

    // the arguments (the files) to be processed
    _vJavaSourceFiles = findFiles(cl.getArgList(), cl.hasOption("recursive"));

    if (cl.hasOption("gui")) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
        }

        JavancssFrame pJavancssFrame = new JavancssFrame(cl.getArgList());
        /* final Thread pThread = Thread.currentThread(); */
        pJavancssFrame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent event) {
                setExit();
            }
        });
        pJavancssFrame.setVisible(true);

        try {
            _measureRoot(newReader(System.in));
        } catch (Throwable pThrowable) {
            // shouldn't we print something here?
            // error details have been written into lastError
        }

        pJavancssFrame.showJavancss(this);
        pJavancssFrame.setSelectedTab(JavancssFrame.S_PACKAGES);

        return;
    }

    // this initiates the measurement
    try {
        _measureRoot(newReader(System.in));
    } catch (Throwable pThrowable) {
        log.fine("Javancss.<init>(String[]).e: " + pThrowable);
        pThrowable.printStackTrace(System.err);
    }
    if (getLastErrorMessage() != null) {
        System.err.println(getLastErrorMessage() + "\n");
        if (getNcss() <= 0) {
            return;
        }
    }

    String sOutputFile = cl.getOptionValue("out");
    OutputStream out = System.out;
    if (sOutputFile != null) {
        try {
            out = new FileOutputStream(normalizeFileName(sOutputFile));
        } catch (Exception exception) {
            System.err.println("Error opening output file '" + sOutputFile + "': " + exception.getMessage());
            sOutputFile = null;
        }
    }
    // TODO: encoding configuration support for result output
    final PrintWriter pw = useXML() ? new PrintWriter(new OutputStreamWriter(out, "UTF-8"))
            : new PrintWriter(out);
    try {

        format(pw, cl.hasOption("package"), cl.hasOption("object"), cl.hasOption("function"),
                cl.hasOption("all"));

    } finally {
        if (sOutputFile != null) {
            pw.close();
        } else {
            // stdout is used: don't close but ensure everything is flushed
            pw.flush();
        }
    }
}

From source file:chibi.gemmaanalysis.LinkEvalCli.java

@Override
@SuppressWarnings("static-access")
protected void buildOptions() {
    Option goMetricOption = OptionBuilder.hasArg().withArgName("Choice of GO Metric")
            .withDescription("resnik, lin, jiang, percent, cosine, kappa; default = simple")
            .withLongOpt("metric").create('m');
    addOption(goMetricOption);/*  w w  w  .  jav a  2 s. c o  m*/

    Option maxOption = OptionBuilder.hasArg().withArgName("Choice of using MAX calculation")
            .withDescription("MAX").withLongOpt("max").create('x');
    addOption(maxOption);

    Option weightedOption = OptionBuilder.hasArg().withArgName("Choice of using weighted matrix")
            .withDescription("weight").withLongOpt("weight").create('w');
    addOption(weightedOption);

    Option dataOption = OptionBuilder.hasArg()
            .withArgName("Choice of generating random gene pairs OR Input data file")
            .withDescription("dataType").isRequired().create('d');
    addOption(dataOption);

    Option taxonOption = OptionBuilder.hasArg().withArgName("Choice of taxon")
            .withDescription("human, rat, mouse").isRequired().create('t');
    addOption(taxonOption);

    Option firstGeneOption = OptionBuilder.hasArg().withArgName("colindex")
            .withDescription("Column index with gene1 (starting from 0; default=0)").create("g1col");
    Option secondGeneOption = OptionBuilder.hasArg().withArgName("colindex")
            .withDescription("Column index with gene2 (starting from 0; default=1)").create("g2col");
    addOption(firstGeneOption);
    addOption(secondGeneOption);

    Option arrayDesignOption = OptionBuilder.hasArg().isRequired().withArgName("Array Design")
            .withDescription("Short Name of Platform").create("array");
    addOption(arrayDesignOption);

    Option numberOfRandomRunsOption = OptionBuilder.hasArg().withArgName("Number of Random Runs")
            .withDescription(
                    "Number of runs for random gene pair selection from array design (starting from 1; default = 1)")
            .create("runs");
    addOption(numberOfRandomRunsOption);

    Option outFileOption = OptionBuilder.hasArg().isRequired().withArgName("outFile")
            .withDescription("Write output to this file").create('o');
    addOption(outFileOption);

    Option noZeroGo = OptionBuilder.withDescription("Exclude genes with no GO terms").create("noZeroGo");
    addOption(noZeroGo);

    Option print = OptionBuilder.hasArg().withArgName("Output file for random links")
            .withDescription("Print out randomly chosen probe pairs in a separate output file").create("print");
    addOption(print);

    Option probenames = OptionBuilder.hasArg().withArgName("File containing subset of probe names")
            .withDescription(
                    "File containing subset of probe names associated with selected array design from which to choose random pairs")
            .create("probenames");
    addOption(probenames);

    Option subsetOption = OptionBuilder.hasArg()
            .withArgName("Approximate number of probe pairs desired to score from full set")
            .withDescription(
                    "Take random subset of probe pairs approximated to given argument from input file to score")
            .create("subset");
    addOption(subsetOption);

    Option aspectOption = OptionBuilder.hasArg().withArgName("aspect")
            .withDescription("Limit to mf, bp or cc. Default=use all three").create("aspect");
    addOption(aspectOption);

    Option outputGoAnnots = OptionBuilder.hasArg().withArgName("path")
            .withDescription("Also rint out the Gene-GO relationships in a tabbed format").create("termsout");
    addOption(outputGoAnnots);

}

From source file:DcmQR.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();
    OptionBuilder.withArgName("aet[@host][:port]");
    OptionBuilder.hasArg();/*from   w  ww  .  java  2  s . c o  m*/
    OptionBuilder.withDescription("set AET, local address and listening port of local Application Entity");
    opts.addOption(OptionBuilder.create("L"));

    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"));

    opts.addOption("nossl2", false, "disable SSLv2Hello TLS handshake");
    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_1.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");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("retrieve instances of matching entities by C-MOVE to specified destination.");
    opts.addOption(OptionBuilder.create("cmove"));

    opts.addOption("cget", false, "retrieve instances of matching entities by C-GET.");

    OptionBuilder.withArgName("cuid[:ts]");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription("negotiate support of specified Storage SOP Class and Transfer "
            + "Syntaxes. The Storage SOP\nClass may be specified by its UID "
            + "or by one\nof following key words:\n" + "CR  - Computed Radiography Image Storage\n"
            + "CT  - CT Image Storage\n" + "MR  - MRImageStorage\n" + "US  - Ultrasound Image Storage\n"
            + "NM  - Nuclear Medicine Image Storage\n" + "PET - PET Image Storage\n"
            + "SC  - Secondary Capture Image Storage\n" + "XA  - XRay Angiographic Image Storage\n"
            + "XRF - XRay Radiofluoroscopic Image Storage\n"
            + "DX  - Digital X-Ray Image Storage for Presentation\n"
            + "                            MG  - Digital Mammography X-Ray Image Storage\n"
            + "for Presentation\n" + "PR  - Grayscale Softcopy Presentation State Storage\n"
            + "                            KO  - Key Object Selection Document Storage\n"
            + "SR  - Basic Text Structured Report Document Storage\n"
            + "                            The Transfer Syntaxes may be specified by a comma\n"
            + "                            separated list of UIDs or by one of following key\n"
            + "                            words:\n"
            + "                            IVRLE - offer only Implicit VR Little Endian\n"
            + "                            Transfer Syntax\n"
            + "                            LE - offer Explicit and Implicit VR Little Endian\n"
            + "                            Transfer Syntax\n"
            + "                            BE - offer Explicit VR Big Endian Transfer Syntax\n"
            + "                            DEFL - offer Deflated Explicit VR Little\n"
            + "                            Endian Transfer Syntax\n"
            + "                            JPLL - offer JEPG Loss Less Transfer Syntaxes\n"
            + "                            JPLY - offer JEPG Lossy Transfer Syntaxes\n"
            + "                            MPEG2 - offer MPEG2 Transfer Syntax\n"
            + "                            NOPX - offer No Pixel Data Transfer Syntax\n"
            + "                            NOPXD - offer No Pixel Data Deflate Transfer Syntax\n"
            + "                            If only the Storage SOP Class is specified, all\n"
            + "                            Transfer Syntaxes listed above except No Pixel Data\n"
            + "                            and No Pixel Data Delflate Transfer Syntax are\n"
            + "                            offered.");
    opts.addOption(OptionBuilder.create("cstore"));

    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("store received objects into files in specified directory <dir>."
            + " Do not store received objects\nby default.");
    opts.addOption(OptionBuilder.create("cstoredest"));

    opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax.");

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "maximum number of outstanding C-MOVE-RQ " + "it may invoke asynchronously, 1 by default.");
    opts.addOption(OptionBuilder.create("async"));

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximum number of outstanding storage operations performed "
            + "asynchronously, unlimited by\n                            default.");
    opts.addOption(OptionBuilder.create("storeasync"));

    opts.addOption("noextneg", false, "disable extended negotiation.");
    opts.addOption("rel", false, "negotiate support of relational queries and retrieval.");
    opts.addOption("datetime", false, "negotiate support of combined date and time attribute range matching.");
    opts.addOption("fuzzy", false, "negotiate support of fuzzy semantic person name attribute matching.");

    opts.addOption("retall", false,
            "negotiate private FIND SOP Classes " + "to fetch all available attributes of matching entities.");
    opts.addOption("blocked", false,
            "negotiate private FIND SOP Classes "
                    + "to return attributes of several matching entities per FIND\n"
                    + "                            response.");
    opts.addOption("vmf", false,
            "negotiate private FIND SOP Classes to "
                    + "return attributes of legacy CT/MR images of one series as\n"
                    + "                           virtual multiframe object.");
    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\n" + "                           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("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 C-FIND-RSP, 60s by default");
    opts.addOption(OptionBuilder.create("cfindrspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving C-MOVE-RSP and C-GET RSP, 600s by default");
    opts.addOption(OptionBuilder.create("cmoverspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving C-GET-RSP and C-MOVE RSP, 600s by default");
    opts.addOption(OptionBuilder.create("cgetrspTO"));

    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("minimal buffer size to write received object to file, 1KB by default");
    opts.addOption(OptionBuilder.create("filebuf"));

    OptionGroup qrlevel = new OptionGroup();

    OptionBuilder.withDescription(
            "perform patient level query, multiple " + "exclusive with -S and -I, perform study level query\n"
                    + "                            by default.");
    OptionBuilder.withLongOpt("patient");
    opts.addOption(OptionBuilder.create("P"));

    OptionBuilder.withDescription(
            "perform series level query, multiple " + "exclusive with -P and -I, perform study level query\n"
                    + "                            by default.");
    OptionBuilder.withLongOpt("series");
    opts.addOption(OptionBuilder.create("S"));

    OptionBuilder.withDescription(
            "perform instance level query, multiple " + "exclusive with -P and -S, perform study level query\n"
                    + "                            by default.");
    OptionBuilder.withLongOpt("image");
    opts.addOption(OptionBuilder.create("I"));

    opts.addOptionGroup(qrlevel);

    OptionBuilder.withArgName("[seq/]attr=value");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription(
            "specify matching key. attr can be " + "specified by name or tag value (in hex), e.g. PatientName\n"
                    + "or 00100010. Attributes in nested Datasets can\n"
                    + "be specified by including the name/tag value of\n"
                    + "                            the sequence attribute, e.g. 00400275/00400009\n"
                    + "for Scheduled Procedure Step ID in the Request\n" + "Attributes Sequence");
    opts.addOption(OptionBuilder.create("q"));

    OptionBuilder.withArgName("attr");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription(
            "specify additional return key. attr can " + "be specified by name or tag value (in hex).");
    opts.addOption(OptionBuilder.create("r"));

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "cancel query after receive of specified " + "number of responses, no cancel by default");
    opts.addOption(OptionBuilder.create("C"));

    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("retrieve matching objects to specified " + "move destination.");
    opts.addOption(OptionBuilder.create("cmove"));

    opts.addOption("evalRetrieveAET", false, "Only Move studies not allready stored on destination AET");
    opts.addOption("lowprior", false, "LOW priority of the C-FIND/C-MOVE operation, MEDIUM by default");
    opts.addOption("highprior", false, "HIGH priority of the C-FIND/C-MOVE operation, MEDIUM by default");

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("repeat query (and retrieve) several times");
    opts.addOption(OptionBuilder.create("repeat"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("delay in ms between repeated query (and retrieve), no delay by default");
    opts.addOption(OptionBuilder.create("repeatdelay"));

    opts.addOption("reuseassoc", false, "Reuse association for repeated query (and retrieve)");
    opts.addOption("closeassoc", false, "Close association between repeated query (and retrieve)");

    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("dcmqr: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmQR.class.getPackage();
        System.out.println("dcmqr v" + p.getImplementationVersion());
        System.exit(0);
    }
    if (cl.hasOption('h') || cl.getArgList().size() != 1) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
        System.exit(0);
    }

    return cl;
}

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();//  w w  w. ja  v  a2 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:mod.org.dcm4che2.tool.DcmQR.java

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*from ww w.  ja v  a  2 s  . com*/
    OptionBuilder.withDescription("set device name, use DCMQR 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"));

    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_1.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");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("retrieve instances of matching entities by C-MOVE to specified destination.");
    opts.addOption(OptionBuilder.create("cmove"));

    opts.addOption("nocfind", false,
            "retrieve instances without previous query - unique keys must be specified by -q options");

    opts.addOption("cget", false, "retrieve instances of matching entities by C-GET.");

    OptionBuilder.withArgName("cuid[:ts]");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription("negotiate support of specified Storage SOP Class and Transfer "
            + "Syntaxes. The Storage SOP Class may be specified by its UID "
            + "or by one of following key words:\n" + "CR  - Computed Radiography Image Storage\n"
            + "CT  - CT Image Storage\n" + "MR  - MRImageStorage\n" + "US  - Ultrasound Image Storage\n"
            + "NM  - Nuclear Medicine Image Storage\n" + "PET - PET Image Storage\n"
            + "SC  - Secondary Capture Image Storage\n" + "XA  - XRay Angiographic Image Storage\n"
            + "XRF - XRay Radiofluoroscopic Image Storage\n"
            + "DX  - Digital X-Ray Image Storage for Presentation\n"
            + "MG  - Digital Mammography X-Ray Image Storage for Presentation\n"
            + "PR  - Grayscale Softcopy Presentation State Storage\n"
            + "KO  - Key Object Selection Document Storage\n"
            + "SR  - Basic Text Structured Report Document Storage\n"
            + "The Transfer Syntaxes may be specified by a comma "
            + "separated list of UIDs or by one of following key " + "words:\n"
            + "IVRLE - offer only Implicit VR Little Endian " + "Transfer Syntax\n"
            + "LE - offer Explicit and Implicit VR Little Endian " + "Transfer Syntax\n"
            + "BE - offer Explicit VR Big Endian Transfer Syntax\n"
            + "DEFL - offer Deflated Explicit VR Little " + "Endian Transfer Syntax\n"
            + "JPLL - offer JEPG Loss Less Transfer Syntaxes\n" + "JPLY - offer JEPG Lossy Transfer Syntaxes\n"
            + "MPEG2 - offer MPEG2 Transfer Syntax\n" + "NOPX - offer No Pixel Data Transfer Syntax\n"
            + "NOPXD - offer No Pixel Data Deflate Transfer Syntax\n"
            + "If only the Storage SOP Class is specified, all "
            + "Transfer Syntaxes listed above except No Pixel Data "
            + "and No Pixel Data Delflate Transfer Syntax are " + "offered.");
    opts.addOption(OptionBuilder.create("cstore"));

    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("store received objects into files in specified directory <dir>."
            + " Do not store received objects by default.");
    opts.addOption(OptionBuilder.create("cstoredest"));

    opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax.");

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "maximum number of outstanding C-MOVE-RQ " + "it may invoke asynchronously, 1 by default.");
    opts.addOption(OptionBuilder.create("async"));

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("maximum number of outstanding storage operations performed "
            + "asynchronously, unlimited by default.");
    opts.addOption(OptionBuilder.create("storeasync"));

    opts.addOption("noextneg", false, "disable extended negotiation.");
    opts.addOption("rel", false, "negotiate support of relational queries and retrieval.");
    opts.addOption("datetime", false, "negotiate support of combined date and time attribute range matching.");
    opts.addOption("fuzzy", false, "negotiate support of fuzzy semantic person name attribute matching.");

    opts.addOption("retall", false,
            "negotiate private FIND SOP Classes " + "to fetch all available attributes of matching entities.");
    opts.addOption("blocked", false, "negotiate private FIND SOP Classes "
            + "to return attributes of several matching entities per FIND " + "response.");
    opts.addOption("vmf", false, "negotiate private FIND SOP Classes to "
            + "return attributes of legacy CT/MR images of one series as " + "virtual multiframe object.");
    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("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 C-FIND-RSP, 60s by default");
    opts.addOption(OptionBuilder.create("cfindrspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving C-MOVE-RSP and C-GET RSP, 600s by default");
    opts.addOption(OptionBuilder.create("cmoverspTO"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("timeout in ms for receiving C-GET-RSP and C-MOVE RSP, 600s by default");
    opts.addOption(OptionBuilder.create("cgetrspTO"));

    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("minimal buffer size to write received object to file, 1KB by default");
    opts.addOption(OptionBuilder.create("filebuf"));

    OptionGroup qrlevel = new OptionGroup();

    OptionBuilder.withDescription("perform patient level query, multiple "
            + "exclusive with -S and -I, perform study level query " + "by default.");
    OptionBuilder.withLongOpt("patient");
    qrlevel.addOption(OptionBuilder.create("P"));

    OptionBuilder.withDescription("perform series level query, multiple "
            + "exclusive with -P and -I, perform study level query " + "by default.");
    OptionBuilder.withLongOpt("series");
    qrlevel.addOption(OptionBuilder.create("S"));

    OptionBuilder.withDescription("perform instance level query, multiple "
            + "exclusive with -P and -S, perform study level query " + "by default.");
    OptionBuilder.withLongOpt("image");
    qrlevel.addOption(OptionBuilder.create("I"));

    OptionBuilder.withArgName("cuid");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription("negotiate addition private C-FIND SOP " + "class with specified UID");
    opts.addOption(OptionBuilder.create("cfind"));

    opts.addOptionGroup(qrlevel);

    OptionBuilder.withArgName("[seq/]attr=value");
    OptionBuilder.hasArgs();
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription(
            "specify matching key. attr can be " + "specified by name or tag value (in hex), e.g. PatientName "
                    + "or 00100010. Attributes in nested Datasets can "
                    + "be specified by including the name/tag value of "
                    + "the sequence attribute, e.g. 00400275/00400009 "
                    + "for Scheduled Procedure Step ID in the Request " + "Attributes Sequence");
    opts.addOption(OptionBuilder.create("q"));

    OptionBuilder.withArgName("attr");
    OptionBuilder.hasArgs();
    OptionBuilder.withDescription(
            "specify additional return key. attr can " + "be specified by name or tag value (in hex).");
    opts.addOption(OptionBuilder.create("r"));

    opts.addOption("nodefret", false, "only inlcude return keys specified by -r into the request.");

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "cancel query after receive of specified " + "number of responses, no cancel by default");
    opts.addOption(OptionBuilder.create("C"));

    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("retrieve matching objects to specified " + "move destination.");
    opts.addOption(OptionBuilder.create("cmove"));

    opts.addOption("evalRetrieveAET", false, "Only Move studies not allready stored on destination AET");
    opts.addOption("lowprior", false, "LOW priority of the C-FIND/C-MOVE operation, MEDIUM by default");
    opts.addOption("highprior", false, "HIGH priority of the C-FIND/C-MOVE operation, MEDIUM by default");

    OptionBuilder.withArgName("num");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("repeat query (and retrieve) several times");
    opts.addOption(OptionBuilder.create("repeat"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("delay in ms between repeated query (and retrieve), no delay by default");
    opts.addOption(OptionBuilder.create("repeatdelay"));

    opts.addOption("reuseassoc", false, "Reuse association for repeated query (and retrieve)");
    opts.addOption("closeassoc", false, "Close association between repeated query (and retrieve)");

    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("dcmqr: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = DcmQR.class.getPackage();
        System.out.println("dcmqr v" + p.getImplementationVersion());
        System.exit(0);
    }
    if (cl.hasOption('h') || cl.getArgList().size() != 1) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
        System.exit(0);
    }

    return cl;
}

From source file:fr.iphc.grid.jobmonitor.CeList.java

@SuppressWarnings("static-access")
protected Options createOptions() {
    Options opt = new Options();
    /*/* ww  w .jav a2  s  .  c  o m*/
     * opt.addOption(OptionBuilder.create()); OptionBuilder.withDescription(
     * "Display this help and exit");
     * OptionBuilder.withLongOpt(LONGOPT_HELP);
     * opt.addOption(OptionBuilder.create(OPT_HELP));
     * 
     * 
     * OptionBuilder.create(); OptionBuilder.withDescription(
     * "Output file directory"); OptionBuilder.hasArg();
     * OptionBuilder.withArgName("OutDir");
     * OptionBuilder.withLongOpt(LONGOPT_OUTDIR);
     * opt.addOption(OptionBuilder.create(OPT_OUTDIR));
     * 
     * OptionBuilder.create(); OptionBuilder.withDescription(
     * "Waiting TimeOut in minutes"); OptionBuilder.hasArg();
     * OptionBuilder.withArgName("timeout");
     * OptionBuilder.withLongOpt(LONGOPT_TIMEOUT);
     * opt.addOption(OptionBuilder.create(OPT_TIMEOUT));
     * 
     * 
     * OptionGroup reqGroup = new OptionGroup(); OptionBuilder.create();
     * OptionBuilder.withDescription("read job description from file <path>"
     * ); OptionBuilder.hasArg(); OptionBuilder.withArgName("path");
     * OptionBuilder.withLongOpt(LONGOPT_FILE);
     * reqGroup.addOption(OptionBuilder.create(OPT_FILE));
     * OptionBuilder.create(); OptionBuilder.withDescription(
     * "command to execute"); OptionBuilder.hasArg();
     * reqGroup.addOption(OptionBuilder.create(JobDescription.EXECUTABLE));
     * reqGroup.setRequired(false); opt.addOptionGroup(reqGroup);
     */

    // command
    opt.addOption(OptionBuilder.withDescription("Display this help and exit").withLongOpt(LONGOPT_HELP)
            .create(OPT_HELP));

    // required arguments
    opt.addOption(OptionBuilder.withDescription("the URL of the job service").hasArg().withArgName("URL")
            .withLongOpt(LONGOPT_RESOURCE).create(OPT_RESOURCE));

    opt.addOption(OptionBuilder
            .withDescription("generate the job description in the targeted grid language "
                    + "and exit (do not submit the job)")
            .withLongOpt(LONGOPT_DESCRIPTION).create(OPT_DESCRIPTION));

    opt.addOption(OptionBuilder.withDescription("Output file directory").hasArg().withArgName("OutDir")
            .withLongOpt(LONGOPT_OUTDIR).create(OPT_OUTDIR));

    opt.addOption(OptionBuilder.withDescription("Waiting TimeOut in minutes").hasArg().withArgName("timeout")
            .withLongOpt(LONGOPT_TIMEOUT).create(OPT_TIMEOUT));

    opt.addOption(OptionBuilder.withDescription("File with CE/Path Format: CREAM://host:8443/path").hasArg()
            .withArgName("ce_path").withLongOpt(LONGOPT_CEPATH).create(OPT_CEPATH));

    // optional group
    OptionGroup optGroup = new OptionGroup();
    optGroup.addOption(OptionBuilder
            .withDescription(
                    "print the job identifier as soon as it is submitted, " + "and wait for it to be finished")
            .withLongOpt(LONGOPT_JOBID).create(OPT_JOBID));
    optGroup.addOption(OptionBuilder
            .withDescription("print the job identifier as soon as it is submitted, " + "and exit immediatly.")
            .withLongOpt(LONGOPT_BATCH).create(OPT_BATCH));
    optGroup.setRequired(false);
    opt.addOptionGroup(optGroup);

    OptionGroup reqGroup = new OptionGroup();
    reqGroup.addOption(OptionBuilder.withDescription("read job description from file <path>").hasArg()
            .withArgName("path").withLongOpt(LONGOPT_FILE).create(OPT_FILE));
    reqGroup.addOption(o("command to execute").hasArg().create(JobDescription.EXECUTABLE));
    // reqGroup.setRequired(true);
    opt.addOptionGroup(reqGroup);

    // job description
    opt.addOption(o("positional parameters for the command").hasArgs().create(JobDescription.ARGUMENTS));
    opt.addOption(o("SPMD job type and startup mechanism").hasArg().create(JobDescription.SPMDVARIATION));
    opt.addOption(
            o("total number of cpus requested for this job").hasArg().create(JobDescription.TOTALCPUCOUNT));
    opt.addOption(o("number of process instances to start").hasArg().create(JobDescription.NUMBEROFPROCESSES));
    opt.addOption(o("number of processes to start per host").hasArg().create(JobDescription.PROCESSESPERHOST));
    opt.addOption(
            o("expected number of threads per process").hasArg().create(JobDescription.THREADSPERPROCESS));
    opt.addOption(o("set of environment variables for the job").hasArgs().withValueSeparator()
            .create(JobDescription.ENVIRONMENT));
    opt.addOption(o("working directory for the job").hasArg().create(JobDescription.WORKINGDIRECTORY));
    opt.addOption(o("run the job in interactive mode").create(JobDescription.INTERACTIVE));
    opt.addOption(o("pathname of the standard input file").hasArg().create(JobDescription.INPUT));
    opt.addOption(o("pathname of the standard output file").hasArg().create(JobDescription.OUTPUT));
    opt.addOption(o("pathname of the standard error file").hasArg().create(JobDescription.ERROR));
    opt.addOption(o("a list of file transfer directives").hasArgs().create(JobDescription.FILETRANSFER));
    opt.addOption(o("defines if output files get removed after the job finishes").hasArg()
            .create(JobDescription.CLEANUP));
    opt.addOption(o("time at which a job should be scheduled").hasArg().create(JobDescription.JOBSTARTTIME));
    opt.addOption(o("hard limit for the total job runtime").hasArg().create(JobDescription.WALLTIMELIMIT));
    opt.addOption(o("estimated total number of CPU seconds which the job will require").hasArg()
            .create(JobDescription.TOTALCPUTIME));
    opt.addOption(o("estimated amount of memory the job requires").hasArg()
            .create(JobDescription.TOTALPHYSICALMEMORY));
    opt.addOption(o("compatible processor for job submission").hasArg().create(JobDescription.CPUARCHITECTURE));
    opt.addOption(o("compatible operating system for job submission").hasArg()
            .create(JobDescription.OPERATINGSYSTEMTYPE));
    opt.addOption(
            o("list of host names which are to be considered by the resource manager as candidate targets")
                    .hasArgs().create(JobDescription.CANDIDATEHOSTS));
    opt.addOption(o("name of a queue to place the job into").hasArg().create(JobDescription.QUEUE));
    opt.addOption(o("name of an account or project name").hasArg().create(JobDescription.JOBPROJECT));
    opt.addOption(o("set of endpoints describing where to report").hasArgs().create(JobDescription.JOBCONTACT));

    // returns
    return opt;
}

From source file:com.cloudera.sqoop.tool.BaseSqoopTool.java

protected RelatedOptions getHBaseOptions() {
    RelatedOptions hbaseOpts = new RelatedOptions("HBase arguments");
    hbaseOpts.addOption(OptionBuilder.withArgName("table").hasArg()
            .withDescription("Import to <table> in HBase").withLongOpt(HBASE_TABLE_ARG).create());
    hbaseOpts.addOption(OptionBuilder.withArgName("family").hasArg()
            .withDescription("Sets the target column family for the import").withLongOpt(HBASE_COL_FAM_ARG)
            .create());//  w w w.  j av a  2 s.  co  m
    hbaseOpts.addOption(OptionBuilder.withArgName("col").hasArg()
            .withDescription("Specifies which input column to use as the row key")
            .withLongOpt(HBASE_ROW_KEY_ARG).create());
    hbaseOpts.addOption(OptionBuilder.withDescription("If specified, create missing HBase tables")
            .withLongOpt(HBASE_CREATE_TABLE_ARG).create());

    return hbaseOpts;
}

From source file:io.werval.cli.DamnSmallDevShell.java

@SuppressWarnings("static-access")
private static Options declareOptions() {
    Option classpathOption = OptionBuilder.withArgName("element").hasArgs()
            .withDescription("Set application classpath element. "
                    + "Use this option several times to declare a full classpath. ")
            .withLongOpt("classpath").create('c');

    Option sourcesOption = OptionBuilder.withArgName("directory").hasArgs()
            .withDescription("Set application sources directories. "
                    + "Use this option several times to declare multiple sources directories. "
                    + "Defaults to 'src/main/java' and 'src/main/resources' in current directory.")
            .withLongOpt("sources").create('s');

    Option tmpdirOption = OptionBuilder.withArgName("directory").hasArgs()
            .withDescription("Set temporary directory. Defaults to 'build/devshell.tmp' in current directory.")
            .withLongOpt("tmpdir").create('t');

    Option propertiesOption = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator()
            .withDescription("Define a system property. "
                    + "Use this option several times to define multiple system properties. "
                    + "Particularly convenient when used to override application configuration.")
            .withLongOpt("define").create('D');

    Option debugOption = OptionBuilder.withDescription("Enable debug output.").withLongOpt("debug").create('d');

    Option versionOption = OptionBuilder.withDescription("Display version information.").withLongOpt("version")
            .create();/*www .  j  a v a2 s.c o m*/

    Option helpOption = OptionBuilder.withDescription("Display help information.").withLongOpt("help").create();

    Options options = new Options();
    options.addOption(classpathOption);
    options.addOption(sourcesOption);
    options.addOption(tmpdirOption);
    options.addOption(propertiesOption);
    options.addOption(debugOption);
    options.addOption(versionOption);
    options.addOption(helpOption);
    return options;
}

From source file:edu.umd.cs.buildServer.BuildServerDaemon.java

/**
 * Command-line interface./*w  w  w.  j av  a  2 s .  c  om*/
 */

@SuppressWarnings("static-access")
public static Options getOptions() {
    Options options = new Options();
    Option configFile = OptionBuilder.withArgName("file").hasArg().withDescription("use given config file")
            .withLongOpt("config").create("c");
    Option courseKey = OptionBuilder.withArgName("courseKey").hasArg().withDescription("use given course key")
            .create("course");
    Option downloadOnly = OptionBuilder.withDescription("download only").withLongOpt("downloadOnly")
            .create("d");
    Option submission = OptionBuilder.withArgName("submissionPK").hasArg()
            .withDescription("test the specified submission").withLongOpt("submission").create("s");

    Option quiet = OptionBuilder.withDescription("no output; no warnings if already running")
            .withLongOpt("quiet").create("q");

    Option testSetup = OptionBuilder.withArgName("testSetupPK").hasArg()
            .withDescription("use the specified test setup").withLongOpt("testSetup").create("t");

    Option projectNum = OptionBuilder.withArgName("projectNum").hasArg()
            .withDescription("exhaustively retest the specified project").withLongOpt("projectNum").create("p");
    Option skipDownload = OptionBuilder.withDescription("don't download submission").create("skipDownload");

    Option onceOption = new Option("o", "once", false, "quit after handling one request");
    Option logLevel = OptionBuilder.withArgName("logLevel").hasArg().withDescription("Log4j log level")
            .withLongOpt("logLevel").create("l");
    Option help = new Option("h", "help", false, "print this message");
    Option verifyOnly = OptionBuilder.withDescription("just verify connection to submit server")
            .withLongOpt("verify").create("v");
    options.addOption(help);
    options.addOption(configFile);
    options.addOption(submission);
    options.addOption(skipDownload);

    options.addOption(projectNum);
    options.addOption(courseKey);

    options.addOption(testSetup);
    options.addOption(onceOption);
    options.addOption(logLevel);
    options.addOption(quiet);
    options.addOption(downloadOnly);
    options.addOption(verifyOnly);
    return options;
}

From source file:ca.gnewton.lusql.core.LuSqlMain.java

static void setupOptions() {

    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Subquery in the form \"field|A:A:A|sql\" or \"field|A:A:A A:A:A...|sql\" or \"field|sql\"  (See -i for A:A:A values). Note that you can have multiple -Qs. Also note that putting a '*' before the field indicates you want the results cached (useful only if there is a possible for subsequent cache hits. Use only if you know what you are doing.")
            .create("Q"));

    options.addOption(OptionBuilder.hasArgs().withDescription(
            "For DocSinks (Indexes) that support multiple real indexes, either to eventual merging or as-is")
            .create("L"));

    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Set static Document field and value. This is a field that has the same value for all saved documents. Format: \"field=value\" or \"A:A:A:field=value\" (See -i for A:A:A values)")
            .create("g"));

    options.addOption(OptionBuilder.hasArg()
            .withDescription(//  ww  w.  j  a v  a  2s  .  c  o  m
                    "Full name class implementing Lucene Analyzer; Default: " + LuSql.DefaultAnalyzerClassName)
            .create("a"));

    options.addOption(OptionBuilder.hasArg()
            .withDescription(
                    "Offset # documents to ignore before indexing. Default:" + LuSqlFields.OffsetDefault)
            .create("O"));

    options.addOption(OptionBuilder.hasArg().withDescription(
            "Full name class implementing DocSink (the index class). Default: " + LuSql.DefaultDocSinkClassName)
            .create(CLIDocSinkClassName));

    options.addOption(OptionBuilder.hasArg()
            .withDescription("Full name class implementing DocSource (the index class). Default: "
                    + LuSql.DefaultDocSourceClassName)
            .create("so"));

    options.addOption(OptionBuilder.hasArg().withDescription(
            "Primary key field name fron DocSource to be used in DocSink. Only for DocSinks that need it. Lucene does not. BDB does. For JDBCDocSource, if not set, uses first field in SQL query.")
            .create("P"));

    options.addOption("A", false, "Append to existing Lucene index.");

    options.addOption(OptionBuilder.hasArg()
            .withDescription("Queue size for multithreading. Default: numThreads * 50").create("S"));

    options.addOption(OptionBuilder.hasArg().withDescription(
            "Tries to limit activity to keep load average below this (float) value. Can reduce performance. Default: "
                    + LuSql.loadAverageLimit)
            .create("V"));

    options.addOption("J", false, "For multiple indexes (see -L) do not merge. Default: false");

    options.addOption("X", false, "Print out command line arguments");

    options.addOption("Y", false, "Silent output");

    options.addOption("o", false, "If supported, have DocSink write to stdout");

    //////////////////////////
    options.addOption(OptionBuilder.hasArg()
            //.isRequired()
            .withDescription(
                    "JDBC connection URL: REQUIRED _OR_ Source location (Source dependent: file, url, etc)")
            .create("c"));

    //////////////////////////
    options.addOption(OptionBuilder.hasArg()
            .withDescription("Verbose output chunk size. Default:" + LuSqlFields.DefaultChunkSize).create("C"));

    //////////////////////////
    options.addOption(OptionBuilder.hasArg()
            .withDescription("Amount of documents to be processed per thread. Default:"
                    + LuSqlFields.DefaultWorkPerThread
                    + ". Increasing tends to improve throughput; Decreasing tends to reduce memory problems and can alleviate an \"Out of memory\" exception. Should be 5-100 for medium/small documents. Should be 1 for very large documents.")
            .create("w"));

    //////////////////////////
    options.addOption(OptionBuilder.hasArg()
            .withDescription("Full name of DB driver class (should be in CLASSPATH); Default: "
                    + LuSql.DefaultJDBCDriverClassName)
            .create("d"));

    //////////////////////////
    options.addOption(OptionBuilder.hasArgs()
            .withDescription("Full name class implementing DocumentFilter; Default: "
                    + LuSql.DefaultDocFilterClassName
                    + " (does nothing). This is applied before each Lucene Document is added to the Index. If it returns null, nothing is added. Note that multiple filters are allowed. They are applied in the same order as they appear in the command line.")
            .create(CLIDocFiltersClassName));

    //////////////////////////
    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Only include these fields from DocSource. Example: -F author -F id. Is absolute (i.e. even if you have additional fields - like in your SQL query - they will be filtered out.")
            .create("F"));

    //////////////////////////
    options.addOption("I", true,
            "Global field index parameters. This sets all the fields parameters to this one set. Format: A:A:A. See -i for A:A:A values. Note that -i has precedence over -I.");

    //////////////////////////
    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Size of internal arrays of documents. One of these arrays is put on the queue. So the number of objects waiting to be processed is K*S (array size * queue size). For small objects have more (k=100). For large objects have fewer (k=5). Default: "
                    + LuSqlFields.DefaultDocPacketSize)
            .create("K"));

    //////////////////////////
    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Full name plugin class; Get description and properties options needed by specific plugin (filter, source, or sink.")
            .create("e"));

    StringBuilder sb = new StringBuilder();
    sb.append("One set per field in SQL, and in same order as in SQL. ");
    sb.append("Used only if you want to overide the defaults (below). ");
    sb.append("See for more information Field.Index, Field.Store, Field.TermVector in");
    sb.append(
            "org.apache.lucene.document.Field http://lucene.apache.org/java/3_0_2/api/core/org/apache/lucene/document/Field.html");
    //http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/document/Field.html");
    sb.append("\nDefault: A:A:A= "
            //+ Util.getIndex(LuSql.IndexDefault, IndexParameterValues) 
            //+ Util.getIndex(LuSql.StoreDefault, StoreParameterValues) 
            //+ Util.getIndex(LuSql.TermVectorDefault, TermVectorParameterValues) 
            + LuceneFieldParameters.rindex.get(LuSql.defaultLuceneFieldParameters.getIndex()) + ":"
            + LuceneFieldParameters.rstorex.get(LuSql.defaultLuceneFieldParameters.getStore()) + ":"
            + LuceneFieldParameters.rtermx.get(LuSql.defaultLuceneFieldParameters.getTermVector()));

    sb.append("\nField Index Parameter values:");
    sb.append("\nIndex: Default: "
            + LuceneFieldParameters.rindex.get(LuSql.defaultLuceneFieldParameters.getIndex()));
    sb.append("\n");

    Set<String> names = LuceneFieldParameters.indexx.keySet();
    for (String name : names) {
        sb.append("\n-  " + name);
    }

    sb.append("\nStore: Default: "
            + LuceneFieldParameters.rstorex.get(LuSql.defaultLuceneFieldParameters.getStore()));

    sb.append("\n");
    names = LuceneFieldParameters.storex.keySet();
    for (String name : names) {
        sb.append("\n-  " + name);
    }
    sb.append("\n Term vector: Default: "
            + LuceneFieldParameters.rtermx.get(LuSql.defaultLuceneFieldParameters.getTermVector()));

    sb.append("\n");
    names = LuceneFieldParameters.termx.keySet();
    for (String name : names) {
        sb.append("\n-  " + name);
    }
    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Field index parameters. \nFormat: \"fieldName=A:A:A\". Note that -i can have a slightly different interpretation depending on the DocSource. For DocSource implementation where the syntax of the query allows for separate definition of the query and the fields of interest (like SQL), all of the fields defined in the query are stored/indexed. For other DocSource's where only the query can be defined and the fields of interest cannot (like the Lucene syntax of the LucenDocSource), the \"-i\" syntax is the only way to set the fields to be used. "
                    + sb)
            .create("i"));

    //////////////////////
    options.addOption(OptionBuilder.hasArg()
            //.isRequired()
            .withDescription("Sink destination (i.e. Lucene index to create/write to). Default: "
                    + LuSql.DefaultSinkLocationName)
            .create("l"));

    //////////////////////
    options.addOption("N", true,
            "Number of thread for multithreading. Defaults: Runtime.getRuntime().availableProcessors()) *"
                    + LuSql.ThreadFactor + ". For this machine this is: "
                    + (Runtime.getRuntime().availableProcessors() * LuSql.ThreadFactor));

    //////////////////////
    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Properties to be passed to the DocSource driver. Can be is multiple. Example: -pso foo=bar  -pso \"start=test 4\"")
            .create("pso"));

    //////////////////////
    options.addOption(OptionBuilder.hasArgs()
            .withDescription(
                    "Properties to be passed to the DocSink driver. Can be multiple. See 'pso' for examples")
            .create("psi"));

    //////////////////////
    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Properties to be passed to a filter. Can be multiple. Identify filter using integer (zero is the first filter). Example: -pf 0:size=10 -pf 0:name=fred -pf 1:reduce=true")
            .create("pf"));

    //////////////////////
    options.addOption(OptionBuilder
            .withDescription("Read from source using source driver's internal compression, if it supports it")
            .create("zso"));

    options.addOption(OptionBuilder
            .withDescription("Have sink driver use internal compression (opaque), if it supports it")
            .create("zsi"));

    //////////////////////
    options.addOption("n", true, "Number of documents to add. If unset all records from query are used.");

    //////////////////////
    options.addOption("M", true,
            "Changes the meta replacement string for the -Q command line parameters. Default: "
                    + SubQuery.getKeyMeta());

    //////////////////////
    options.addOption("m", false,
            "Turns off need get around MySql driver-caused OutOfMemory problem in large queries. Sets Statement.setFetchSize(Integer.MIN_VALUE)"
                    + "\n See http://benjchristensen.wordpress.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset");

    //////////////////////
    options.addOption(OptionBuilder.hasArg().withDescription("Set JDBC Transaction level. Default: "
            + DefaultTransactionIsolation + ". Values:\n" + Connection.TRANSACTION_NONE + " TRANSACTION_NONE\n"
            + Connection.TRANSACTION_READ_UNCOMMITTED + " TRANSACTION_READ_UNCOMMITTED\n"
            + Connection.TRANSACTION_READ_COMMITTED + " TRANSACTION_READ_COMMITTED\n"
            + Connection.TRANSACTION_REPEATABLE_READ + " TRANSACTION_REPEATABLE_READ\n"
            + Connection.TRANSACTION_SERIALIZABLE + " TRANSACTION_SERIALIZABLE\n "
            + "(See http://java.sun.com/j2se/1.5.0/docs/api/constant-values.html#java.sql.Connection.TRANSACTION_NONE)")
            .create("E"));

    //////////////////////
    options.addOption("p", true, "Properties file");

    //////////////////////
    //////////////////////
    options.addOption(OptionBuilder.hasArg()
            //.isRequired()
            .withDescription("Primary SQL query (in double quotes). Only used by JDBC driver").create("q"));

    //////////////////////
    options.addOption("r", true,
            "LuceneRAMBufferSizeInMBs: IndexWriter.setRAMBufferSizeMB(). Only used by Lucene sinks. Default: "
                    + Double.toString(LuSql.DefaultRAMBufferSizeMB));

    //////////////////////
    options.addOption("s", true,
            "Name of stop word file to use (relative or full path). If supported by DocSource");

    //////////////////////
    options.addOption("T", false,
            "Turn off multithreading. Note that multithreading does not guarantee the ordering of documents. If you want the order of Lucene documents to match the ordering of DB records generated by the SQL query, turn-off multithreading");

    //////////////////////
    options.addOption("t", false,
            "Test mode. Does not open up Lucene index. Prints (-n) records from SQL query");

    //////////////////////
    options.addOption("v", false, "Verbose mode");

    //////////////////////
    options.addOption("onlyMap", false, "Only use the fields from the DocSource that are mapped using -map");

    options.addOption(OptionBuilder.hasArgs().withDescription(
            "Field map. Transforms field names in DocSource to new fieldnames: Example -map \"AU=author\", where \"AU\" is the original (source) field name and \"author\" is the new (sink) field")
            .create("map"));
}