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

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

Introduction

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

Prototype

public static OptionBuilder withLongOpt(String newLongopt) 

Source Link

Document

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

Usage

From source file:org.dcm4che.tool.mkkos.MkKOS.java

@SuppressWarnings("static-access")
public static void addOptions(Options opts) {
    opts.addOption(OptionBuilder.hasArg().withArgName("code").withDescription(rb.getString("title"))
            .withLongOpt("title").create());
    opts.addOption(OptionBuilder.hasArg().withArgName("code").withDescription(rb.getString("modifier"))
            .withLongOpt("modifier").create());
    opts.addOption(OptionBuilder.hasArg().withArgName("file|url").withDescription(rb.getString("code-config"))
            .withLongOpt("code-config").create());
    opts.addOption(OptionBuilder.hasArg().withArgName("text").withDescription(rb.getString("desc"))
            .withLongOpt("desc").create());
    opts.addOption(OptionBuilder.hasArg().withArgName("no").withDescription(rb.getString("series-no"))
            .withLongOpt("series-no").create());
    opts.addOption(OptionBuilder.hasArg().withArgName("no").withDescription(rb.getString("inst-no"))
            .withLongOpt("inst-no").create());
    opts.addOption(/*from www.java2  s .  c o m*/
            OptionBuilder.hasArg().withArgName("file").withDescription(rb.getString("o-file")).create("o"));
    OptionGroup group = new OptionGroup();
    group.addOption(OptionBuilder.withLongOpt("no-fmi").withDescription(rb.getString("no-fmi")).create("F"));
    group.addOption(OptionBuilder.withLongOpt("transfer-syntax").hasArg().withArgName("uid")
            .withDescription(rb.getString("transfer-syntax")).create("t"));
    opts.addOptionGroup(group);
    opts.addOption(OptionBuilder.hasArgs().withArgName("[seq/]attr=value").withValueSeparator('=')
            .withDescription(rb.getString("set")).create("s"));
    opts.addOption(OptionBuilder.hasArg().withArgName("suffix").withDescription(rb.getString("uid-suffix"))
            .withLongOpt("uid-suffix").create(null));
    CLIUtils.addEncodingOptions(opts);
}

From source file:org.dcm4che.tool.xml2dcm.Xml2Dcm.java

@SuppressWarnings("static-access")
private static void addBulkdataOptions(Options opts) {
    OptionGroup blkGroup = new OptionGroup();
    blkGroup.addOption(/*  w w  w  .jav  a  2s  . c o m*/
            OptionBuilder.withLongOpt("no-bulkdata").withDescription(rb.getString("no-bulkdata")).create("B"));
    blkGroup.addOption(OptionBuilder.withLongOpt("alloc-bulkdata")
            .withDescription(rb.getString("alloc-bulkdata")).create("b"));
    opts.addOptionGroup(blkGroup);
    opts.addOption(OptionBuilder.withLongOpt("blk-file-dir").hasArg().withArgName("directory")
            .withDescription(rb.getString("blk-file-dir")).create("d"));
    opts.addOption(OptionBuilder.withLongOpt("blk-file-prefix").hasArg().withArgName("prefix")
            .withDescription(rb.getString("blk-file-prefix")).create());
    opts.addOption(OptionBuilder.withLongOpt("blk-file-suffix").hasArg().withArgName("suffix")
            .withDescription(rb.getString("blk-file-suffix")).create());
    opts.addOption("c", "cat-blk-files", false, rb.getString("cat-blk-files"));
    opts.addOption(null, "keep-blk-files", false, rb.getString("keep-blk-files"));
    opts.addOption(OptionBuilder.withLongOpt("blk-spec").hasArg().withArgName("xml-file")
            .withDescription(rb.getString("blk-spec")).create("X"));
}

From source file:org.dcm4che.tool.xml2dcm.Xml2Dcm.java

@SuppressWarnings("static-access")
private static void addFileEncodingOptions(Options opts) {
    opts.addOption(OptionBuilder.withLongOpt("transfer-syntax").hasArg().withArgName("uid")
            .withDescription(rb.getString("transfer-syntax")).create("t"));
    OptionGroup fmiGroup = new OptionGroup();
    fmiGroup.addOption(OptionBuilder.withLongOpt("no-fmi").withDescription(rb.getString("no-fmi")).create("F"));
    fmiGroup.addOption(OptionBuilder.withLongOpt("fmi").withDescription(rb.getString("fmi")).create("f"));
    opts.addOptionGroup(fmiGroup);//www. j a  v  a 2  s .co m
    CLIUtils.addEncodingOptions(opts);
}

From source file:org.dcm4che2.tool.dcm2dcm.Dcm2Dcm.java

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

    opts.addOption(null, "no-fmi", false, "Encode result without File Meta Information. At default, "
            + " File Meta Information is included.");
    opts.addOption("e", "explicit", false, "Encode result with Explicit VR Little Endian Transfer Syntax. "
            + "At default, Implicit VR Little Endian is used.");
    opts.addOption("b", "big-endian", false, "Encode result with Explicit VR Big Endian Transfer Syntax. "
            + "At default, Implicit VR Little Endian is used.");
    opts.addOption("z", "deflated", false, "Encode result with Deflated Explicit VR Little Endian Syntax. "
            + "At default, Implicit VR Little Endian is used.");

    OptionBuilder.withArgName("[seq/]attr=value");
    OptionBuilder.hasArgs(2);// w w w. j  a v a2 s .  co m
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withDescription(
            "specify value to set in the output stream.  Currently only works when transcoding images.");
    opts.addOption(OptionBuilder.create("s"));

    opts.addOption("t", "syntax", true,
            "Encode result with the specified transfer syntax - recodes" + " the image typically.");

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

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

From source file:org.dcm4che2.tool.dcmqr.DcmQR.java

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

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();/*from  w  w w .jav  a2s .  c om*/
    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");
    opts.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");
    opts.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");
    opts.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"));

    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:org.dcm4che2.tool.fixjpegls.FixJpegLS.java

@SuppressWarnings("static-access")
private static CommandLine parseCommandLine(String[] args) throws ParseException {
    Options options = new Options();
    options.addOption(/*  ww  w.j a v a 2  s .  c  o m*/
            OptionBuilder.withLongOpt("no-check-impl-cuid").withDescription(NO_CHECK_IMPL_CUID).create());
    options.addOption(OptionBuilder.withLongOpt("check-impl-cuid").hasArg().withArgName("uid")
            .withDescription(CHECK_IMPL_CUID).create());
    options.addOption(OptionBuilder.withLongOpt("no-new-impl-cuid").withDescription(NO_NEW_IMPL_CUID).create());
    options.addOption(OptionBuilder.withLongOpt("new-impl-cuid").hasArg().withArgName("uid")
            .withDescription(NEW_IMPL_CUID).create());
    options.addOption(OptionBuilder.withLongOpt("help").withDescription("display this help and exit").create());
    options.addOption(OptionBuilder.withLongOpt("version")
            .withDescription("output version information and exit").create());
    CommandLineParser parser = new PosixParser();
    CommandLine cl = parser.parse(options, args);
    if (cl.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, options, EXAMPLE);
        return null;
    }
    if (cl.hasOption("version")) {
        System.out.println("fixjpegls " + FixJpegLS.class.getPackage().getImplementationVersion());
        return null;
    }
    return cl;
}

From source file:org.dcm4che2.tool.jpg2dcm.Jpg2Dcm.java

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

    OptionBuilder.withArgName("code");
    OptionBuilder.hasArg();//from ww  w  .j  a  va2  s  .c om
    OptionBuilder.withDescription(OPT_CHARSET_DESC);
    OptionBuilder.withLongOpt(LONG_OPT_CHARSET);
    opts.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(OPT_AUGMENT_CONFIG_DESC);
    opts.addOption(OptionBuilder.create("c"));

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(OPT_REPLACE_CONFIG_DESC);
    opts.addOption(OptionBuilder.create("C"));

    OptionBuilder.withArgName("prefix");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(OPT_UID_PREFIX_DESC);
    OptionBuilder.withLongOpt(LONG_OPT_UID_PREFIX);
    opts.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("uid");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(OPT_TRANSFER_SYNTAX_DESC);
    OptionBuilder.withLongOpt(LONG_OPT_TRANSFER_SYNTAX);
    opts.addOption(OptionBuilder.create());

    opts.addOption(null, LONG_OPT_MPEG, false, OPT_MPEG_DESC);

    opts.addOption(null, LONG_OPT_NO_APPN, false, OPT_NO_APPN_DESC);

    opts.addOption("h", "help", false, OPT_HELP_DESC);
    opts.addOption("V", "version", false, OPT_VERSION_DESC);

    CommandLine cl = null;
    try {
        cl = new PosixParser().parse(opts, args);
    } catch (ParseException e) {
        exit("jpg2dcm: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = Jpg2Dcm.class.getPackage();
        System.out.println("jpg2dcm v" + p.getImplementationVersion());
        System.exit(0);
    }
    if (cl.hasOption('h') || cl.getArgList().size() != 2) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
        System.exit(0);
    }

    return cl;
}

From source file:org.dcm4che3.tool.dcm2json.Dcm2Json.java

@SuppressWarnings("static-access")
private static void addBulkdataOptions(Options opts) {
    OptionGroup group = new OptionGroup();
    group.addOption(/*  ww  w  .  ja  va  2 s . c  om*/
            OptionBuilder.withLongOpt("no-bulkdata").withDescription(rb.getString("no-bulkdata")).create("B"));
    group.addOption(OptionBuilder.withLongOpt("with-bulkdata").withDescription(rb.getString("with-bulkdata"))
            .create("b"));
    opts.addOptionGroup(group);
    opts.addOption(OptionBuilder.withLongOpt("blk-file-dir").hasArg().withArgName("directory")
            .withDescription(rb.getString("blk-file-dir")).create("d"));
    opts.addOption(OptionBuilder.withLongOpt("blk-file-prefix").hasArg().withArgName("prefix")
            .withDescription(rb.getString("blk-file-prefix")).create());
    opts.addOption(OptionBuilder.withLongOpt("blk-file-suffix").hasArg().withArgName("suffix")
            .withDescription(rb.getString("blk-file-dir")).create());
    opts.addOption("c", "cat-blk-files", false, rb.getString("cat-blk-files"));
    opts.addOption(OptionBuilder.withLongOpt("blk-spec").hasArg().withArgName("json-file")
            .withDescription(rb.getString("blk-spec")).create("J"));
}

From source file:org.dcm4che3.tool.dcmldap.DcmLdap.java

@SuppressWarnings("static-access")
private static CommandLine parseComandLine(String[] args, OptionGroup cmdGroup) throws ParseException {
    Options opts = new Options();
    CLIUtils.addCommonOptions(opts);/* www .  j  a  v a  2 s .  c  o  m*/
    cmdGroup.addOption(OptionBuilder.hasArg().withArgName("aet@host:port")
            .withDescription(rb.getString("create")).create("c"));
    cmdGroup.addOption(OptionBuilder.hasArg().withArgName("aet@host:port").withDescription(rb.getString("add"))
            .create("a"));
    cmdGroup.addOption(
            OptionBuilder.hasArg().withArgName("aet").withDescription(rb.getString("delete")).create("d"));
    opts.addOptionGroup(cmdGroup);
    opts.addOption(
            OptionBuilder.hasArg().withArgName("ldapuri").withDescription(rb.getString("ldapuri")).create("H"));
    opts.addOption(
            OptionBuilder.hasArg().withArgName("binddn").withDescription(rb.getString("binddn")).create("D"));
    opts.addOption(
            OptionBuilder.hasArg().withArgName("passwd").withDescription(rb.getString("passwd")).create("w"));
    opts.addOption(OptionBuilder.withLongOpt("dev").hasArg().withArgName("name")
            .withDescription(rb.getString("dev")).create(null));
    opts.addOption(OptionBuilder.withLongOpt("dev-desc").hasArg().withArgName("string")
            .withDescription(rb.getString("dev-desc")).create(null));
    opts.addOption(OptionBuilder.withLongOpt("dev-type").hasArg().withArgName("string")
            .withDescription(rb.getString("dev-type")).create(null));
    opts.addOption(OptionBuilder.withLongOpt("ae-desc").hasArg().withArgName("string")
            .withDescription(rb.getString("ae-desc")).create(null));
    opts.addOption(OptionBuilder.withLongOpt("conn").hasArg().withArgName("cn")
            .withDescription(rb.getString("conn-cn")).create(null));
    CLIUtils.addTLSCipherOptions(opts);
    CommandLine cl = CLIUtils.parseComandLine(args, opts, rb, DcmLdap.class);
    String selected = cmdGroup.getSelected();
    if (selected == null)
        throw new ParseException(rb.getString("missing"));
    if (selected.equals("a") && !cl.hasOption("dev"))
        throw new ParseException(rb.getString("missing-dev"));
    return cl;
}

From source file:org.dcm4che3.tool.jpg2dcm.Jpg2Dcm.java

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

    OptionBuilder.withArgName("code");
    OptionBuilder.hasArg();/*from w w w. j  av a2 s.c  om*/
    OptionBuilder.withDescription(OPT_CHARSET_DESC);
    OptionBuilder.withLongOpt(LONG_OPT_CHARSET);
    opts.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(OPT_AUGMENT_CONFIG_DESC);
    opts.addOption(OptionBuilder.create("c"));

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(OPT_REPLACE_CONFIG_DESC);
    opts.addOption(OptionBuilder.create("C"));

    OptionBuilder.withArgName("prefix");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(OPT_UID_PREFIX_DESC);
    OptionBuilder.withLongOpt(LONG_OPT_UID_PREFIX);
    opts.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("uid");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(OPT_TRANSFER_SYNTAX_DESC);
    OptionBuilder.withLongOpt(LONG_OPT_TRANSFER_SYNTAX);
    opts.addOption(OptionBuilder.create());

    opts.addOption(null, LONG_OPT_MPEG, false, OPT_MPEG_DESC);

    opts.addOption(null, LONG_OPT_NO_APPN, false, OPT_NO_APPN_DESC);

    opts.addOption("h", "help", false, OPT_HELP_DESC);
    opts.addOption("V", "version", false, OPT_VERSION_DESC);

    CommandLine cl = null;
    try {
        cl = new PosixParser().parse(opts, args);
    } catch (ParseException e) {
        exit("jpg2dcm: " + e.getMessage());
        throw new RuntimeException("unreachable");
    }
    if (cl.hasOption('V')) {
        Package p = Jpg2Dcm.class.getPackage();
        LOG.info("jpg2dcm v" + p.getImplementationVersion());
        System.exit(0);
    }
    if (cl.hasOption('h') || cl.getArgList().size() != 2) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
        System.exit(0);
    }

    return cl;
}