List of usage examples for org.apache.commons.cli OptionGroup addOption
public OptionGroup addOption(Option option)
Option
to this group. 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 www .j a v a 2 s . com*/ OptionBuilder.withDescription("set device name, use DCMQR by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host][:port]"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set AET, local address and listening port of local" + "Application Entity, use device name and pick up any valid " + "local address to bind the socket by default"); opts.addOption(OptionBuilder.create("L")); OptionBuilder.withArgName("username"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "enable User Identity Negotiation with specified username and " + " optional passcode"); opts.addOption(OptionBuilder.create("username")); OptionBuilder.withArgName("passcode"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "optional passcode for User Identity Negotiation, " + "only effective with option -username"); opts.addOption(OptionBuilder.create("passcode")); opts.addOption("uidnegrsp", false, "request positive User Identity Negotation response, " + "only effective with option -username"); OptionBuilder.withArgName("NULL|3DES|AES"); OptionBuilder.hasArg(); OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption"); opts.addOption(OptionBuilder.create("tls")); OptionGroup tlsProtocol = new OptionGroup(); tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections")); opts.addOptionGroup(tlsProtocol); opts.addOption("noclientauth", false, "disable client authentification for TLS"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_1.p12 by default"); opts.addOption(OptionBuilder.create("keystore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for keystore file, 'secret' by default"); opts.addOption(OptionBuilder.create("keystorepw")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder .withDescription("password for accessing the key in the keystore, keystore password by default"); opts.addOption(OptionBuilder.create("keypw")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default"); opts.addOption(OptionBuilder.create("truststore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for truststore file, 'secret' by default"); opts.addOption(OptionBuilder.create("truststorepw")); OptionBuilder.withArgName("aet"); OptionBuilder.hasArg(); OptionBuilder .withDescription("retrieve instances of matching entities by C-MOVE to specified destination."); opts.addOption(OptionBuilder.create("cmove")); opts.addOption("nocfind", false, "retrieve instances without previous query - unique keys must be specified by -q options"); opts.addOption("cget", false, "retrieve instances of matching entities by C-GET."); OptionBuilder.withArgName("cuid[:ts]"); OptionBuilder.hasArgs(); OptionBuilder.withDescription("negotiate support of specified Storage SOP Class and Transfer " + "Syntaxes. The Storage SOP Class may be specified by its UID " + "or by one of following key words:\n" + "CR - Computed Radiography Image Storage\n" + "CT - CT Image Storage\n" + "MR - MRImageStorage\n" + "US - Ultrasound Image Storage\n" + "NM - Nuclear Medicine Image Storage\n" + "PET - PET Image Storage\n" + "SC - Secondary Capture Image Storage\n" + "XA - XRay Angiographic Image Storage\n" + "XRF - XRay Radiofluoroscopic Image Storage\n" + "DX - Digital X-Ray Image Storage for Presentation\n" + "MG - Digital Mammography X-Ray Image Storage for Presentation\n" + "PR - Grayscale Softcopy Presentation State Storage\n" + "KO - Key Object Selection Document Storage\n" + "SR - Basic Text Structured Report Document Storage\n" + "The Transfer Syntaxes may be specified by a comma " + "separated list of UIDs or by one of following key " + "words:\n" + "IVRLE - offer only Implicit VR Little Endian " + "Transfer Syntax\n" + "LE - offer Explicit and Implicit VR Little Endian " + "Transfer Syntax\n" + "BE - offer Explicit VR Big Endian Transfer Syntax\n" + "DEFL - offer Deflated Explicit VR Little " + "Endian Transfer Syntax\n" + "JPLL - offer JEPG Loss Less Transfer Syntaxes\n" + "JPLY - offer JEPG Lossy Transfer Syntaxes\n" + "MPEG2 - offer MPEG2 Transfer Syntax\n" + "NOPX - offer No Pixel Data Transfer Syntax\n" + "NOPXD - offer No Pixel Data Deflate Transfer Syntax\n" + "If only the Storage SOP Class is specified, all " + "Transfer Syntaxes listed above except No Pixel Data " + "and No Pixel Data Delflate Transfer Syntax are " + "offered."); opts.addOption(OptionBuilder.create("cstore")); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("store received objects into files in specified directory <dir>." + " Do not store received objects by default."); opts.addOption(OptionBuilder.create("cstoredest")); opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax."); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "maximum number of outstanding C-MOVE-RQ " + "it may invoke asynchronously, 1 by default."); opts.addOption(OptionBuilder.create("async")); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximum number of outstanding storage operations performed " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("storeasync")); opts.addOption("noextneg", false, "disable extended negotiation."); opts.addOption("rel", false, "negotiate support of relational queries and retrieval."); opts.addOption("datetime", false, "negotiate support of combined date and time attribute range matching."); opts.addOption("fuzzy", false, "negotiate support of fuzzy semantic person name attribute matching."); opts.addOption("retall", false, "negotiate private FIND SOP Classes " + "to fetch all available attributes of matching entities."); opts.addOption("blocked", false, "negotiate private FIND SOP Classes " + "to return attributes of several matching entities per FIND " + "response."); opts.addOption("vmf", false, "negotiate private FIND SOP Classes to " + "return attributes of legacy CT/MR images of one series as " + "virtual multiframe object."); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, pack command and data " + "PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default"); opts.addOption(OptionBuilder.create("connectTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, 50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving C-FIND-RSP, 60s by default"); opts.addOption(OptionBuilder.create("cfindrspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving C-MOVE-RSP and C-GET RSP, 600s by default"); opts.addOption(OptionBuilder.create("cmoverspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving C-GET-RSP and C-MOVE RSP, 600s by default"); opts.addOption(OptionBuilder.create("cgetrspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default"); opts.addOption(OptionBuilder.create("acceptTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("minimal buffer size to write received object to file, 1KB by default"); opts.addOption(OptionBuilder.create("filebuf")); OptionGroup qrlevel = new OptionGroup(); OptionBuilder.withDescription("perform patient level query, multiple " + "exclusive with -S and -I, perform study level query " + "by default."); OptionBuilder.withLongOpt("patient"); 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.dcmsnd.DcmSnd.java
private static CommandLine parse(String[] args) throws Exception { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();/*from w w w .ja v a2s . c om*/ OptionBuilder.withDescription("set device name, use DCMSND by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host][:port]"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set AET, local address and listening port of local " + "Application Entity, use device name and pick up any valid " + "local address to bind the socket by default"); opts.addOption(OptionBuilder.create("L")); opts.addOption("ts1", false, "offer Default Transfer Syntax in " + "separate Presentation Context. By default offered with " + "Explicit VR Little Endian TS in one PC."); opts.addOption("fileref", false, "send objects without pixel data, but with a reference to " + "the DICOM file using DCM4CHE URI Referenced Transfer Syntax " + "to import DICOM objects on a given file system to a DCM4CHEE " + "archive."); OptionBuilder.withArgName("username"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "enable User Identity Negotiation with specified username and " + " optional passcode"); opts.addOption(OptionBuilder.create("username")); OptionBuilder.withArgName("passcode"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "optional passcode for User Identity Negotiation, " + "only effective with option -username"); opts.addOption(OptionBuilder.create("passcode")); opts.addOption("uidnegrsp", false, "request positive User Identity Negotation response, " + "only effective with option -username"); OptionBuilder.withArgName("NULL|3DES|AES"); OptionBuilder.hasArg(); OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption"); opts.addOption(OptionBuilder.create("tls")); OptionGroup tlsProtocol = new OptionGroup(); tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections")); opts.addOptionGroup(tlsProtocol); opts.addOption("noclientauth", false, "disable client authentification for TLS"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default"); opts.addOption(OptionBuilder.create("keystore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for keystore file, 'secret' by default"); opts.addOption(OptionBuilder.create("keystorepw")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder .withDescription("password for accessing the key in the keystore, keystore password by default"); opts.addOption(OptionBuilder.create("keypw")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default"); opts.addOption(OptionBuilder.create("truststore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for truststore file, 'secret' by default"); opts.addOption(OptionBuilder.create("truststorepw")); OptionBuilder.withArgName("aet@host:port"); OptionBuilder.hasArg(); OptionBuilder.withDescription("request storage commitment of (successfully) sent objects " + "afterwards in new association to specified remote " + "Application Entity"); opts.addOption(OptionBuilder.create("stgcmtae")); opts.addOption("stgcmt", false, "request storage commitment of (successfully) sent objects " + "afterwards in same association"); OptionBuilder.withArgName("attr=value"); OptionBuilder.hasArgs(); OptionBuilder.withValueSeparator('='); OptionBuilder.withDescription("Replace value of specified attribute " + "with specified value in transmitted objects. attr can be " + "specified by name or tag value (in hex), e.g. PatientName " + "or 00100010."); opts.addOption(OptionBuilder.create("set")); OptionBuilder.withArgName("sx1[:sx2[:sx3]"); OptionBuilder.hasArgs(); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription( "Suffix SOP [,Series [,Study]] " + "Instance UID with specified value[s] in transmitted objects."); opts.addOption(OptionBuilder.create("setuid")); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximum number of outstanding operations it may invoke " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("async")); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, " + "pack command and data PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default"); opts.addOption(OptionBuilder.create("connectTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, " + "50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for closing the listening socket, " + "1000ms by default"); opts.addOption(OptionBuilder.create("shutdowndelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, " + "10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("rspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default"); opts.addOption(OptionBuilder.create("acceptTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("transcoder buffer size in KB, 1KB by default"); opts.addOption(OptionBuilder.create("bufsize")); opts.addOption("lowprior", false, "LOW priority of the C-STORE operation, MEDIUM by default"); opts.addOption("highprior", false, "HIGH priority of the C-STORE operation, MEDIUM by default"); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmsnd: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = DcmSnd.class.getPackage(); System.out.println("dcmsnd v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() < 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); //System.exit( 0 ); throw new RuntimeException(); } return cl; }
From source file:org.dcm4che2.tool.dcmups.DcmUPS.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();//w ww .j a v a 2s .c o m OptionBuilder.withDescription("set device name, use DCMGPWL by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host]"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set AET and local address 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")); opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax."); opts.addOption("fuzzy", false, "negotiate support of fuzzy semantic person name attribute matching."); 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 DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("rspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default"); opts.addOption(OptionBuilder.create("acceptTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("state"); OptionBuilder.hasArg(); OptionBuilder.withDescription("match/change UPS of/to specified <state>"); opts.addOption(OptionBuilder.create("state")); OptionBuilder.withArgName("file"); OptionBuilder.hasArg(); OptionBuilder.withDescription("path to DICOM or XML file with UPS attributes to create or set."); opts.addOption(OptionBuilder.create("f")); OptionBuilder.withArgName("uid"); OptionBuilder.hasArg(); OptionBuilder.withDescription("SOP Instance UID of UPS. Required for " + "operation set, get, chstate, reqcancel, and for operation " + "subscribe/unsubscribe to/form receiving UPS events about a " + "specific UPS - and not subscribe/unsubscribe globally."); opts.addOption(OptionBuilder.create("iuid")); OptionBuilder.withArgName("uid"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Transaction UID."); opts.addOption(OptionBuilder.create("tuid")); OptionBuilder.withArgName("aet"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "Specifies AET of Requesting AE for " + "operation reqcancel and AET of Receiving AE for operation " + "subscribe, unsubscribe and suspend."); opts.addOption(OptionBuilder.create("aet")); opts.addOption("dellock", false, "invoke operation subscribe with Deletion Lock."); 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. " + "ScheduledProcedureStepStartDateTime or 00404005. " + "Attributes in nested Datasets can be specified by " + "including the name/tag value of the sequence attribute, " + "e.g. 00404018/00080100 for Code Value in the Scheduled " + "Workitem Code Sequence."); opts.addOption(OptionBuilder.create("q")); OptionBuilder.withArgName("attr"); OptionBuilder.hasArgs(); OptionBuilder.withDescription( "specify return key. attr can be " + "specified by name or tag value (in hex). If no return key" + "is specified, defaults are used for invoked find operation."); opts.addOption(OptionBuilder.create("r")); OptionGroup sopClass = new OptionGroup(); sopClass.addOption(new Option("upspush", "Use UPS Push SOP Class to invoke operation. " + "Use appropriate SOP Class by default.")); sopClass.addOption(new Option("upspull", "Use UPS Pull SOP Class to invoke operation. " + "Use appropriate SOP Class by default.")); sopClass.addOption(new Option("upswatch", "Use UPS Watch SOP Class to invoke operation. " + "Use appropriate SOP Class by default.")); opts.addOptionGroup(sopClass); OptionBuilder.withArgName("NORMAL|HIGH|LOW"); OptionBuilder.hasArgs(); OptionBuilder.withDescription("specify priority of the C-FIND " + "operation, NORMAL by default."); opts.addOption(OptionBuilder.create("findprior")); 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("dcmups: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = DcmUPS.class.getPackage(); System.out.println("dcmups v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h')) { 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( 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);/*from w ww. ja v a 2 s .c o m*/ 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);//from w w w. java2 s . c om 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.json2dcm.Json2Dcm.java
@SuppressWarnings("static-access") private static void addBulkdataOptions(Options opts) { OptionGroup blkGroup = new OptionGroup(); blkGroup.addOption( 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);//from w w w . j a v a2s . c o m 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("json-file") .withDescription(rb.getString("blk-spec")).create("J")); }
From source file:org.dspace.eperson.EPerson.java
/** * Tool for manipulating user accounts.// w w w . ja va2s . c om */ public static void main(String argv[]) throws ParseException, SQLException { final OptionGroup VERBS = new OptionGroup(); VERBS.addOption(VERB_ADD); VERBS.addOption(VERB_DELETE); VERBS.addOption(VERB_LIST); VERBS.addOption(VERB_MODIFY); final Options globalOptions = new Options(); globalOptions.addOptionGroup(VERBS); globalOptions.addOption("h", "help", false, "explain options"); GnuParser parser = new GnuParser(); CommandLine command = parser.parse(globalOptions, argv, true); Context context = new Context(); // Disable authorization since this only runs from the local commandline. context.turnOffAuthorisationSystem(); int status = 0; if (command.hasOption(VERB_ADD.getOpt())) { status = cmdAdd(context, argv); } else if (command.hasOption(VERB_DELETE.getOpt())) { status = cmdDelete(context, argv); } else if (command.hasOption(VERB_MODIFY.getOpt())) { status = cmdModify(context, argv); } else if (command.hasOption(VERB_LIST.getOpt())) { status = cmdList(context, argv); } else if (command.hasOption('h')) { new HelpFormatter().printHelp("user [options]", globalOptions); } else { System.err.println("Unknown operation."); new HelpFormatter().printHelp("user [options]", globalOptions); context.abort(); status = 1; throw new IllegalArgumentException(); } if (context.isValid()) { try { context.complete(); } catch (SQLException ex) { System.err.println(ex.getMessage()); } } }
From source file:org.dspace.eperson.EPerson.java
/** Command to create an EPerson. */ private static int cmdAdd(Context context, String[] argv) { Options options = new Options(); options.addOption(VERB_ADD);//from w w w. j a v a 2 s . co m final OptionGroup identityOptions = new OptionGroup(); identityOptions.addOption(OPT_EMAIL); identityOptions.addOption(OPT_NETID); options.addOptionGroup(identityOptions); options.addOption(OPT_GIVENNAME); options.addOption(OPT_SURNAME); options.addOption(OPT_PHONE); options.addOption(OPT_LANGUAGE); options.addOption(OPT_REQUIRE_CERTIFICATE); Option option = new Option("p", "password", true, "password to match the EPerson name"); options.addOption(option); options.addOption("h", "help", false, "explain --add options"); // Rescan the command for more details. GnuParser parser = new GnuParser(); CommandLine command; try { command = parser.parse(options, argv); } catch (ParseException e) { System.err.println(e.getMessage()); return 1; } if (command.hasOption('h')) { new HelpFormatter().printHelp("user --add [options]", options); return 0; } // Check that we got sufficient credentials to define a user. if ((!command.hasOption(OPT_EMAIL.getOpt())) && (!command.hasOption(OPT_NETID.getOpt()))) { System.err.println("You must provide an email address or a netid to identify the new user."); return 1; } if (!command.hasOption('p')) { System.err.println("You must provide a password for the new user."); return 1; } // Create! EPerson eperson = null; try { eperson = create(context); } catch (SQLException ex) { context.abort(); System.err.println(ex.getMessage()); return 1; } catch (AuthorizeException ex) { /* XXX SNH */ } eperson.setCanLogIn(true); eperson.setSelfRegistered(false); eperson.setEmail(command.getOptionValue(OPT_EMAIL.getOpt())); eperson.setFirstName(command.getOptionValue(OPT_GIVENNAME.getOpt())); eperson.setLastName(command.getOptionValue(OPT_SURNAME.getOpt())); eperson.setLanguage(command.getOptionValue(OPT_LANGUAGE.getOpt(), Locale.getDefault().getLanguage())); eperson.setMetadata("phone", command.getOptionValue(OPT_PHONE.getOpt())); eperson.setNetid(command.getOptionValue(OPT_NETID.getOpt())); eperson.setPassword(command.getOptionValue('p')); if (command.hasOption(OPT_REQUIRE_CERTIFICATE.getOpt())) { eperson.setRequireCertificate( Boolean.valueOf(command.getOptionValue(OPT_REQUIRE_CERTIFICATE.getOpt()))); } else { eperson.setRequireCertificate(false); } try { eperson.update(); context.commit(); System.out.printf("Created EPerson %d\n", eperson.getID()); } catch (SQLException ex) { context.abort(); System.err.println(ex.getMessage()); return 1; } catch (AuthorizeException ex) { /* XXX SNH */ } return 0; }
From source file:org.dspace.eperson.EPerson.java
/** Command to delete an EPerson. */ private static int cmdDelete(Context context, String[] argv) { Options options = new Options(); options.addOption(VERB_DELETE);/*from w w w . j a v a 2 s . c om*/ final OptionGroup identityOptions = new OptionGroup(); identityOptions.addOption(OPT_EMAIL); identityOptions.addOption(OPT_NETID); options.addOptionGroup(identityOptions); options.addOption("h", "help", false, "explain --delete options"); GnuParser parser = new GnuParser(); CommandLine command; try { command = parser.parse(options, argv); } catch (ParseException e) { System.err.println(e.getMessage()); return 1; } if (command.hasOption('h')) { new HelpFormatter().printHelp("user --delete [options]", options); return 0; } // Delete! EPerson eperson = null; try { if (command.hasOption(OPT_NETID.getOpt())) { eperson = findByNetid(context, command.getOptionValue(OPT_NETID.getOpt())); } else if (command.hasOption(OPT_EMAIL.getOpt())) { eperson = findByEmail(context, command.getOptionValue(OPT_EMAIL.getOpt())); } else { System.err.println("You must specify the user's email address or netid."); return 1; } } catch (SQLException e) { System.err.append(e.getMessage()); return 1; } catch (AuthorizeException e) { /* XXX SNH */ } if (null == eperson) { System.err.println("No such EPerson"); return 1; } try { eperson.delete(); context.commit(); System.out.printf("Deleted EPerson %d\n", eperson.getID()); } catch (SQLException ex) { System.err.println(ex.getMessage()); return 1; } catch (AuthorizeException ex) { System.err.println(ex.getMessage()); return 1; } catch (EPersonDeletionException ex) { System.err.println(ex.getMessage()); return 1; } return 0; }
From source file:org.dspace.eperson.EPerson.java
/** Command to modify an EPerson. */ private static int cmdModify(Context context, String[] argv) { Options options = new Options(); options.addOption(VERB_MODIFY);// w w w . j a v a2 s . com final OptionGroup identityOptions = new OptionGroup(); identityOptions.addOption(OPT_EMAIL); identityOptions.addOption(OPT_NETID); options.addOptionGroup(identityOptions); options.addOption(OPT_GIVENNAME); options.addOption(OPT_SURNAME); options.addOption(OPT_PHONE); options.addOption(OPT_LANGUAGE); options.addOption(OPT_REQUIRE_CERTIFICATE); options.addOption(OPT_CAN_LOGIN); options.addOption(OPT_NEW_EMAIL); options.addOption(OPT_NEW_NETID); options.addOption("h", "help", false, "explain --modify options"); GnuParser parser = new GnuParser(); CommandLine command; try { command = parser.parse(options, argv); } catch (ParseException e) { System.err.println(e.getMessage()); return 1; } if (command.hasOption('h')) { new HelpFormatter().printHelp("user --modify [options]", options); return 0; } // Modify! EPerson eperson = null; try { if (command.hasOption(OPT_NETID.getOpt())) { eperson = findByNetid(context, command.getOptionValue(OPT_NETID.getOpt())); } else if (command.hasOption(OPT_EMAIL.getOpt())) { eperson = findByEmail(context, command.getOptionValue(OPT_EMAIL.getOpt())); } else { System.err.println("No EPerson selected"); return 1; } } catch (SQLException e) { System.err.append(e.getMessage()); return 1; } catch (AuthorizeException e) { /* XXX SNH */ } boolean modified = false; if (null == eperson) { System.err.println("No such EPerson"); return 1; } else { if (command.hasOption(OPT_NEW_EMAIL.getOpt())) { eperson.setEmail(command.getOptionValue(OPT_NEW_EMAIL.getOpt())); modified = true; } if (command.hasOption(OPT_NEW_NETID.getOpt())) { eperson.setNetid(command.getOptionValue(OPT_NEW_NETID.getOpt())); modified = true; } if (command.hasOption(OPT_GIVENNAME.getOpt())) { eperson.setFirstName(command.getOptionValue(OPT_GIVENNAME.getOpt())); modified = true; } if (command.hasOption(OPT_SURNAME.getOpt())) { eperson.setLastName(command.getOptionValue(OPT_SURNAME.getOpt())); modified = true; } if (command.hasOption(OPT_PHONE.getOpt())) { eperson.setMetadata("phone", command.getOptionValue(OPT_PHONE.getOpt())); modified = true; } if (command.hasOption(OPT_LANGUAGE.getOpt())) { eperson.setLanguage(command.getOptionValue(OPT_LANGUAGE.getOpt())); modified = true; } if (command.hasOption(OPT_REQUIRE_CERTIFICATE.getOpt())) { eperson.setRequireCertificate( Boolean.valueOf(command.getOptionValue(OPT_REQUIRE_CERTIFICATE.getOpt()))); modified = true; } if (command.hasOption(OPT_CAN_LOGIN.getOpt())) { eperson.setCanLogIn(Boolean.valueOf(command.getOptionValue(OPT_CAN_LOGIN.getOpt()))); modified = true; } if (modified) { try { eperson.update(); context.commit(); System.out.printf("Modified EPerson %d\n", eperson.getID()); } catch (SQLException ex) { context.abort(); System.err.println(ex.getMessage()); return 1; } catch (AuthorizeException ex) { /* XXX SNH */ } } else { System.out.println("No changes."); } } return 0; }