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

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

Introduction

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

Prototype

public static OptionBuilder hasArg() 

Source Link

Document

The next Option created will require an argument value.

Usage

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);/*from   w w w  .j a v 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:daemon.dicomnode.DcmRcv.java

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set device name, use DCMRCV by default");
    opts.addOption(OptionBuilder.create("device"));

    OptionBuilder.withArgName("NULL|3DES|AES");
    OptionBuilder.hasArg();//from ww  w . java2s .com
    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("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("dest"));

    OptionBuilder.withArgName("file|url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("file path or URL of properties for mapping Calling AETs to "
            + "sub-directories of the storage directory specified by "
            + "-dest, to separate the storage location dependend on " + "Calling AETs.");
    opts.addOption(OptionBuilder.create("calling2dir"));

    OptionBuilder.withArgName("file|url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("file path or URL of properties for mapping Called AETs to "
            + "sub-directories of the storage directory specified by "
            + "-dest, to separate the storage location dependend on " + "Called AETs.");
    opts.addOption(OptionBuilder.create("called2dir"));

    OptionBuilder.withArgName("sub-dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("storage sub-directory used for Calling AETs for which no "
            + " mapping is defined by properties specified by " + "-calling2dir, 'OTHER' by default.");
    opts.addOption(OptionBuilder.create("callingdefdir"));

    OptionBuilder.withArgName("sub-dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("storage sub-directory used for Called AETs for which no "
            + " mapping is defined by properties specified by " + "-called2dir, 'OTHER' by default.");
    opts.addOption(OptionBuilder.create("calleddefdir"));

    OptionBuilder.withArgName("dir");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("register stored objects in cache journal files in specified directory <dir>."
            + " Do not register stored objects by default.");
    opts.addOption(OptionBuilder.create("journal"));

    OptionBuilder.withArgName("pattern");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("cache journal file path, with "
            + "'yyyy' will be replaced by the current year, "
            + "'MM' by the current month, 'dd' by the current date, "
            + "'HH' by the current hour and 'mm' by the current minute. " + "'yyyy/MM/dd/HH/mm' by default.");
    opts.addOption(OptionBuilder.create("journalfilepath"));

    opts.addOption("defts", false, "accept only default transfer syntax.");
    opts.addOption("bigendian", false, "accept also Explict VR Big Endian transfer syntax.");
    opts.addOption("native", false, "accept only transfer syntax with uncompressed pixel data.");

    OptionGroup scRetrieveAET = new OptionGroup();
    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Retrieve AE Title included in Storage Commitment "
            + "N-EVENT-REPORT in items of the Referenced SOP Sequence.");
    scRetrieveAET.addOption(OptionBuilder.create("scretraets"));
    OptionBuilder.withArgName("aet");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Retrieve AE Title included in Storage Commitment "
            + "N-EVENT-REPORT outside of the Referenced SOP Sequence.");
    scRetrieveAET.addOption(OptionBuilder.create("scretraet"));
    opts.addOptionGroup(scRetrieveAET);

    opts.addOption("screusefrom", false,
            "attempt to issue the Storage Commitment N-EVENT-REPORT on "
                    + "the same Association on which the N-ACTION operation was "
                    + "performed; use different Association for N-EVENT-REPORT by " + "default.");

    opts.addOption("screuseto", false,
            "attempt to issue the Storage Commitment N-EVENT-REPORT on "
                    + "previous initiated Association to the Storage Commitment SCU; "
                    + "initiate new Association for N-EVENT-REPORT by default.");

    OptionBuilder.withArgName("port");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("port of Storage Commitment SCU to connect to issue "
            + "N-EVENT-REPORT on different Association; 104 by default.");
    opts.addOption(OptionBuilder.create("scport"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder
            .withDescription("delay in ms for N-EVENT-REPORT-RQ to Storage Commitment SCU, " + "1s by default");
    opts.addOption(OptionBuilder.create("scdelay"));

    OptionBuilder.withArgName("retry");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "number of retries to issue N-EVENT-REPORT-RQ to Storage " + "Commitment SCU, 0 by default");
    opts.addOption(OptionBuilder.create("scretry"));

    OptionBuilder.withArgName("ms");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("interval im ms between retries to issue N-EVENT-REPORT-RQ to"
            + "Storage Commitment SCU, 60s by default");
    opts.addOption(OptionBuilder.create("scretryperiod"));

    OptionBuilder.withArgName("maxops");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "maximum number of outstanding operations performed " + "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("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("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 DIMSE-RSP; useful for testing asynchronous mode");
    opts.addOption(OptionBuilder.create("rspdelay"));

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

    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("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-RQ, 60s by default");
    opts.addOption(OptionBuilder.create("idleTO"));

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

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

From source file:ml.shifu.shifu.util.ShifuCLI.java

/**
 * Build the usage option for parameter check
 *///from www  . jav  a2  s.  c  o m
@SuppressWarnings("static-access")
private static Options buildModelSetOptions(String[] args) {
    Options opts = new Options();

    Option opt_cmt = OptionBuilder.hasArg().withDescription("The description for new model")
            .create(MODELSET_CMD_M);
    Option opt_new = OptionBuilder.hasArg().withDescription("To create an eval set").create(NEW);
    Option opt_type = OptionBuilder.hasArg().withDescription("Specify model type").create(MODELSET_CMD_TYPE);
    Option opt_run = OptionBuilder.hasArg().withDescription("To run eval set").create(EVAL_CMD_RUN);
    Option opt_dry = OptionBuilder.hasArg(false).withDescription("Dry run the train").create(TRAIN_CMD_DRY);
    Option opt_debug = OptionBuilder.hasArg(false).withDescription("Save the log of train process")
            .create(TRAIN_CMD_DEBUG);
    Option opt_model = OptionBuilder.hasArg(false).withDescription("Init model").create(INIT_CMD_MODEL);

    Option opt_list = OptionBuilder.hasArg(false).create(LIST);
    Option opt_delete = OptionBuilder.hasArg().create(DELETE);
    Option opt_score = OptionBuilder.hasArg().create(SCORE);
    Option opt_confmat = OptionBuilder.hasArg().create(CONFMAT);
    Option opt_perf = OptionBuilder.hasArg().create(PERF);

    Option opt_save = OptionBuilder.hasArg(false).withDescription("save model").create(SAVE);
    Option opt_switch = OptionBuilder.hasArg(false).withDescription("switch model").create(SWITCH);
    Option opt_eval_model = OptionBuilder.hasArg().withDescription("").create(EVAL_MODEL);

    opts.addOption(opt_cmt);
    opts.addOption(opt_new);
    opts.addOption(opt_type);
    opts.addOption(opt_run);
    opts.addOption(opt_perf);
    opts.addOption(opt_dry);
    opts.addOption(opt_debug);
    opts.addOption(opt_model);

    opts.addOption(opt_list);
    opts.addOption(opt_delete);
    opts.addOption(opt_score);
    opts.addOption(opt_confmat);
    opts.addOption(opt_save);
    opts.addOption(opt_switch);
    opts.addOption(opt_eval_model);

    return opts;
}

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(// www.j a  v  a2 s  .  co  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"));
}

From source file:DcmQR.java

private static CommandLine parse(String[] args) {
    Options opts = new Options();
    OptionBuilder.withArgName("aet[@host][:port]");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set AET, local address and listening port of local Application Entity");
    opts.addOption(OptionBuilder.create("L"));

    OptionBuilder.withArgName("username");
    OptionBuilder.hasArg();/*from  www  . jav a2 s  .c o m*/
    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:mod.org.dcm4che2.tool.DcmQR.java

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("set device name, use DCMQR by default");
    opts.addOption(OptionBuilder.create("device"));

    OptionBuilder.withArgName("aet[@host][:port]");
    OptionBuilder.hasArg();/*from  ww w  .  j ava2 s  .  co  m*/
    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:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private static Option createPortfolioNameOption() {
    OptionBuilder.withLongOpt("portfolio");
    OptionBuilder.withDescription("The name of the portfolio to create/update");
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("resource");
    OptionBuilder.isRequired();/*from  w  w  w. j  av  a  2 s .  co  m*/
    return OptionBuilder.create(PORTFOLIO_NAME_OPT);
}

From source file:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private static Option createOptionDepthOption() {
    OptionBuilder.withLongOpt("depth");
    OptionBuilder.withDescription("Number of options on either side of the strike price");
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("resource");
    OptionBuilder.isRequired();//from ww w  .ja v  a 2 s .  c  o m
    return OptionBuilder.create(OPTION_DEPTH_OPT);
}

From source file:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private static Option createNumContractsOption() {
    OptionBuilder.withLongOpt("contracts");
    OptionBuilder.withDescription("Number of contracts for each option");
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("resource");
    OptionBuilder.isRequired();/*  w  ww . j ava  2 s .c o m*/
    return OptionBuilder.create(NUM_CONTRACTS_OPT);
}

From source file:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private static Option createNumMembersOption() {
    OptionBuilder.withLongOpt("members");
    OptionBuilder.withDescription("Number underlyers from index to include");
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("resource");
    OptionBuilder.isRequired();//from w  w  w.  j a  v a 2s .  co m
    return OptionBuilder.create(NUM_INDEX_MEMBERS_OPT);
}