List of usage examples for org.apache.commons.cli OptionBuilder withDescription
public static OptionBuilder withDescription(String newDescription)
From source file:com.bluemarsh.jswat.console.Main.java
/** * Process the given command line arguments. * * @param args command line arguments. * @throws ParseException if argument parsing fails. *//* w ww . j a va 2 s . c o m*/ private static void processArguments(String[] args) throws ParseException { Options options = new Options(); // Option: h/help OptionBuilder.withDescription(NbBundle.getMessage(Main.class, "MSG_Main_Option_help")); OptionBuilder.withLongOpt("help"); options.addOption(OptionBuilder.create("h")); // Option: attach <port> OptionBuilder.hasArg(); OptionBuilder.withArgName("port"); OptionBuilder.withDescription(NbBundle.getMessage(Main.class, "MSG_Main_Option_attach")); options.addOption(OptionBuilder.create("attach")); // Option: sourcepath <path> OptionBuilder.hasArg(); OptionBuilder.withArgName("path"); OptionBuilder.withDescription(NbBundle.getMessage(Main.class, "MSG_Main_Option_sourcepath")); options.addOption(OptionBuilder.create("sourcepath")); // Option: e/emacs OptionBuilder.withDescription(NbBundle.getMessage(Main.class, "MSG_Main_Option_jdb")); options.addOption(OptionBuilder.create("jdb")); // Parse the command line arguments. CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(options, args); // Interrogate the command line options. jdbEmulationMode = line.hasOption("jdb"); if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java com.bluemarsh.jswat.console.Main", options); System.exit(0); } if (line.hasOption("sourcepath")) { Session session = SessionProvider.getCurrentSession(); PathManager pm = PathProvider.getPathManager(session); String path = line.getOptionValue("sourcepath"); List<String> roots = Strings.stringToList(path, File.pathSeparator); pm.setSourcePath(roots); } if (line.hasOption("attach")) { final Session session = SessionProvider.getCurrentSession(); String port = line.getOptionValue("attach"); ConnectionFactory factory = ConnectionProvider.getConnectionFactory(); final JvmConnection connection; try { connection = factory.createSocket("localhost", port); // The actual connection may be made some time from now, // so set up a listener to be notified at that time. connection.addConnectionListener(new ConnectionListener() { @Override public void connected(ConnectionEvent event) { if (session.isConnected()) { // The user already connected to something else. JvmConnection c = event.getConnection(); c.getVM().dispose(); c.disconnect(); } else { session.connect(connection); } } }); connection.connect(); } catch (Exception e) { logger.log(Level.SEVERE, null, e); } } }
From source file:com.cloudera.sqoop.tool.BaseSqoopTool.java
/** * @return RelatedOptions used by job management tools. *//*from ww w . ja v a 2s.co m*/ protected RelatedOptions getJobOptions() { RelatedOptions relatedOpts = new RelatedOptions("Job management arguments"); relatedOpts.addOption(OptionBuilder.withArgName("jdbc-uri").hasArg() .withDescription("Specify JDBC connect string for the metastore").withLongOpt(STORAGE_METASTORE_ARG) .create()); // Create an option-group surrounding the operations a user // can perform on jobs. OptionGroup group = new OptionGroup(); group.addOption(OptionBuilder.withArgName("job-id").hasArg().withDescription("Create a new saved job") .withLongOpt(JOB_CMD_CREATE_ARG).create()); group.addOption(OptionBuilder.withArgName("job-id").hasArg().withDescription("Delete a saved job") .withLongOpt(JOB_CMD_DELETE_ARG).create()); group.addOption(OptionBuilder.withArgName("job-id").hasArg() .withDescription("Show the parameters for a saved job").withLongOpt(JOB_CMD_SHOW_ARG).create()); Option execOption = OptionBuilder.withArgName("job-id").hasArg().withDescription("Run a saved job") .withLongOpt(JOB_CMD_EXEC_ARG).create(); group.addOption(execOption); group.addOption(OptionBuilder.withDescription("List saved jobs").withLongOpt(JOB_CMD_LIST_ARG).create()); relatedOpts.addOptionGroup(group); // Since the "common" options aren't used in the job tool, // add these settings here. relatedOpts.addOption(OptionBuilder.withDescription("Print more information while working") .withLongOpt(VERBOSE_ARG).create()); relatedOpts.addOption( OptionBuilder.withDescription("Print usage instructions").withLongOpt(HELP_ARG).create()); return relatedOpts; }
From source file:DcmSnd.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("aet[@host][:port]"); OptionBuilder.hasArg();//from ww w . ja v a 2s .com OptionBuilder.withDescription("set AET, local address and listening port of local Application Entity"); opts.addOption(OptionBuilder.create("L")); opts.addOption("ts1", false, "offer Default Transfer Syntax in " + "separate Presentation Context. By default offered with\n" + "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\nReferenced Transfer Syntax " + "to import DICOM objects\n 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")); opts.addOption("nossl2", false, "disable acceptance of 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_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\nto 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("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, 60s 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); } return cl; }
From source file:acromusashi.kafka.log.producer.WinApacheLogProducer.java
/** * ???/* w w w. ja v a2 s . co m*/ * * @return ?? */ public static Options createOptions() { Options cliOptions = new Options(); // OptionBuilder.hasArg(true); OptionBuilder.withArgName("WinApacheLogProducer Conf Path"); OptionBuilder.withDescription("WinApacheLogProducer Conf Path"); OptionBuilder.isRequired(true); Option confPathOption = OptionBuilder.create("c"); // OptionBuilder.withDescription("show help"); Option helpOption = OptionBuilder.create("h"); cliOptions.addOption(confPathOption); cliOptions.addOption(helpOption); return cliOptions; }
From source file:com.blockwithme.longdb.tools.DBTool.java
/** Initialization done in this method. */ @SuppressWarnings("static-access") private static void init() throws Exception { PARSER = new PosixParser(); CURR_OPTS = new Options(); HELP_OPTS = new Option("help", "print help message"); VERBOSE_OPT = new Option("v", "verbose"); DB_TYPE_OPT = OptionBuilder.withArgName("dbtype").hasArg() .withDescription("database type of the database to be connected, use -show " + "option to see the list of available database types and instances") .create("type"); DB_INSTANCE_OPT = OptionBuilder.withArgName("instance").hasArg() .withDescription("database instance of the database to be connected, use -show " + "option to see the list of available database types and instances") .create("instance"); DB_DATABASE_NAME_OPT = OptionBuilder.withArgName("database_name").hasArg() .withDescription("select table by table_name").create("d"); OUTPUTFILE_OPT = OptionBuilder.withArgName("file").hasArg().withDescription("use given file for export") .create("o"); DATA_FORMAT = OptionBuilder.withArgName("format").hasArg() .withDescription("supported output file format json/csv").create("f"); INPUTFILE_OPT = OptionBuilder.withArgName("file").hasArg().withDescription("use given file for import") .create("i"); TABLE_OPT = OptionBuilder.withArgName("table_name").hasArg().withDescription("select table by table_name") .create("t"); ROW_OPT = OptionBuilder.withArgName("row_id").hasArg().withDescription("row identifier").create("r"); COMPRESS_OPT = OptionBuilder.withDescription("compress the output file.").create("z"); DESTINATION_DB_TYPE_OPT = OptionBuilder.withArgName("dest_dbtype").hasArg() .withDescription("dbtype of the destination database, use -show " + "option to see the list of available database types and instances") .create("dtype"); DESTINATION_DB_INSTANCE_OPT = OptionBuilder.withArgName("dest_dbtype").hasArg() .withDescription("instance of the destination database, use -show " + "option to see the list of available database types and instances") .create("dinstance"); DESTINATION_TABLE_OPT = OptionBuilder.withArgName("table_name").hasArg() .withDescription("select destination table name ").create("dt"); DESTINATION_DATABASE_NAME_OPT = OptionBuilder.withArgName("database_name").hasArg() .withDescription("select destination database name ").create("dd"); STD_OUT = OptionBuilder.withDescription("Exported data will be written to 'Stdout'").create("stdout"); STD_IN = OptionBuilder.withDescription("Imported data will be read from 'Stdin'").create("stdin"); MERGE_TABLES = OptionBuilder.withDescription("Use 'mergeTables' to import/copy data into existing tables.") .create("mergeTables"); CURR_OPTS.addOption("", true, "valid arguments - help, showtables, showdatabases, export, import, rowcount, " + "columncount, dropdatabase, droptable " + "createdatabase, createtable copy " + NEW_LINE + "example 1: 'DBTool -u cassandra:@localhost:9160:mydb showtables' " + NEW_LINE + "example 2: 'DBTool -u cassandra:embedded:@abc_cluster: showdatabases' " + NEW_LINE + "example 3: 'DBTool -u voltdb:@localhost:mydb -t mytable rowcount' " + NEW_LINE); CURR_OPTS.addOption(HELP_OPTS);/*from w w w . j a va2 s . com*/ CURR_OPTS.addOption(VERBOSE_OPT); CURR_OPTS.addOption(DB_TYPE_OPT); CURR_OPTS.addOption(DB_INSTANCE_OPT); CURR_OPTS.addOption(DB_DATABASE_NAME_OPT); CURR_OPTS.addOption(OUTPUTFILE_OPT); CURR_OPTS.addOption(INPUTFILE_OPT); CURR_OPTS.addOption(TABLE_OPT); CURR_OPTS.addOption(ROW_OPT); CURR_OPTS.addOption(DESTINATION_DB_TYPE_OPT); CURR_OPTS.addOption(DESTINATION_DB_INSTANCE_OPT); CURR_OPTS.addOption(DESTINATION_DATABASE_NAME_OPT); CURR_OPTS.addOption(DESTINATION_TABLE_OPT); CURR_OPTS.addOption(COMPRESS_OPT); CURR_OPTS.addOption(DATA_FORMAT); CURR_OPTS.addOption(STD_OUT); CURR_OPTS.addOption(STD_IN); CURR_OPTS.addOption(MERGE_TABLES); }
From source file:com.aliyun.odps.mapred.bridge.streaming.StreamJob.java
private Option createBoolOption(String name, String desc) { return OptionBuilder.withDescription(desc).create(name); }
From source file:com.cloudera.sqoop.tool.BaseSqoopTool.java
/** * @return RelatedOptions used by most/all Sqoop tools. */// w w w . ja v a2 s . c o m protected RelatedOptions getCommonOptions() { // Connection args (common) RelatedOptions commonOpts = new RelatedOptions("Common arguments"); commonOpts.addOption(OptionBuilder.withArgName("jdbc-uri").hasArg() .withDescription("Specify JDBC connect string").withLongOpt(CONNECT_STRING_ARG).create()); commonOpts.addOption(OptionBuilder.withArgName("conn-manager-class-name").hasArg() .withDescription("Specify connection manager class name").withLongOpt(CONN_MANAGER_CLASS_NAME) .create()); commonOpts.addOption(OptionBuilder.withArgName("class-name").hasArg() .withDescription("Manually specify JDBC driver class to use").withLongOpt(DRIVER_ARG).create()); commonOpts.addOption(OptionBuilder.withArgName("username").hasArg() .withDescription("Set authentication username").withLongOpt(USERNAME_ARG).create()); commonOpts.addOption(OptionBuilder.withArgName("password").hasArg() .withDescription("Set authentication password").withLongOpt(PASSWORD_ARG).create()); commonOpts .addOption(OptionBuilder.withDescription("Read password from console").create(PASSWORD_PROMPT_ARG)); commonOpts.addOption(OptionBuilder.withArgName("dir").hasArg().withDescription("Override $HADOOP_HOME") .withLongOpt(HADOOP_HOME_ARG).create()); // misc (common) commonOpts.addOption(OptionBuilder.withDescription("Print more information while working") .withLongOpt(VERBOSE_ARG).create()); commonOpts.addOption( OptionBuilder.withDescription("Print usage instructions").withLongOpt(HELP_ARG).create()); return commonOpts; }
From source file:com.flaptor.indextank.api.EmbeddedIndexEngine.java
@SuppressWarnings("static-access") private static Options getOptions() { Option baseDir = OptionBuilder.withArgName("base-dir").hasArg().isRequired() .withDescription("The basint e dir").withLongOpt("dir").create("d"); Option basePort = OptionBuilder.withArgName("base-port").hasArg().withDescription("The base port") .withLongOpt("port").create("p"); Option boostSize = OptionBuilder.withArgName("boosts-size").hasArg() .withDescription("Number of available boosts").withLongOpt("boosts").create("b"); Option rtiSize = OptionBuilder.withArgName("rti-size").hasArg() .withDescription("The size limit for the RTI").withLongOpt("rti-size").create("rs"); Option help = OptionBuilder.withDescription("displays this help").withLongOpt("help").create("h"); Option snippets = OptionBuilder.withDescription("Allow snippet generation and field fetching.") .withLongOpt("snippets").create("sn"); Option recover = OptionBuilder.withDescription("Recover documents from the storage.").withLongOpt("recover") .create("r"); Option indexCode = OptionBuilder.withArgName("code").hasArg().isRequired() .withDescription("the index code this indexengine has").withLongOpt("index-code").create("ic"); Option environment = OptionBuilder.withArgName("environment").hasArg().isRequired() .withDescription("environment prefix").withLongOpt("environment-prefix").create("env"); /*/*from www .j a va 2 s. c om*/ * Analyzer argument should receive a JSON string with the following root structure: * - factory: a java type that implements the following static method: org.apache.lucene.analysis.Analyzer buildAnalyzer(Map). * - configuration: a JSON object to be passed to the buildAnalyzer method. */ Option analyzer = OptionBuilder.withArgName("analyzer").hasArg().withDescription("specific analyzer") .withLongOpt("analyzer").create("an"); Option configFile = OptionBuilder.withArgName("conf-file").hasArg().withDescription("configuration file") .withLongOpt("conf-file").create("cf"); Option loadState = OptionBuilder.withArgName("load") .withDescription( "if present, the index engine will try to restore its state" + "from the serialized form.") .withLongOpt("load-state").create("l"); Option suggest = OptionBuilder.withArgName("suggest").hasArg() .withDescription("if present, loads the suggest/autocomplete system.").withLongOpt("suggest") .create("su"); Option facets = OptionBuilder.withArgName("facets") .withDescription("if present, performs facetings queries.").withLongOpt("facets").create("fa"); Option functions = OptionBuilder.withArgName("functions").hasArg() .withDescription( "list of '|' separated scoring functions, each of which has the form <id>:<definition>.") .withLongOpt("functions").create("fn"); Option didyoumean = OptionBuilder.withLongOpt("didyoumean").withDescription( "if present, performs 'did you mean?' suggestions on queries. Requires --suggest documents.") .create("dym"); Option storage = OptionBuilder.withLongOpt("storage").hasArg() .withDescription( "if present, specifies a storage backend. Options are 'bdb' and 'ram'. Defaults to 'ram'.") .create("st"); Option bdbCache = OptionBuilder.withLongOpt("bdb-cache").hasArg().withDescription( "if present, specifies the size of the berkeleyDb cache per thread, in megabytes. Defaults to 100MB.") .create("bc"); Options options = new Options(); options.addOption(baseDir); options.addOption(basePort); options.addOption(boostSize); options.addOption(help); options.addOption(snippets); options.addOption(recover); options.addOption(indexCode); options.addOption(rtiSize); options.addOption(loadState); options.addOption(suggest); options.addOption(facets); options.addOption(functions); options.addOption(environment); options.addOption(analyzer); options.addOption(didyoumean); options.addOption(configFile); options.addOption(storage); options.addOption(bdbCache); return options; }
From source file:com.upload.DcmSnd.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();/*w w w . j av a2 s .com*/ OptionBuilder.withDescription("set device name, use DCMSND by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host][:port]"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set AET, local address and listening port of local " + "Application Entity, use device name and pick up any valid " + "local address to bind the socket by default"); opts.addOption(OptionBuilder.create("L")); opts.addOption("ts1", false, "offer Default Transfer Syntax in " + "separate Presentation Context. By default offered with " + "Explicit VR Little Endian TS in one PC."); opts.addOption("fileref", false, "send objects without pixel data, but with a reference to " + "the DICOM file using DCM4CHE URI Referenced Transfer Syntax " + "to import DICOM objects on a given file system to a DCM4CHEE " + "archive."); OptionBuilder.withArgName("username"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "enable User Identity Negotiation with specified username and " + " optional passcode"); opts.addOption(OptionBuilder.create("username")); OptionBuilder.withArgName("passcode"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "optional passcode for User Identity Negotiation, " + "only effective with option -username"); opts.addOption(OptionBuilder.create("passcode")); opts.addOption("uidnegrsp", false, "request positive User Identity Negotation response, " + "only effective with option -username"); OptionBuilder.withArgName("NULL|3DES|AES"); OptionBuilder.hasArg(); OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption"); opts.addOption(OptionBuilder.create("tls")); OptionGroup tlsProtocol = new OptionGroup(); tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections")); opts.addOptionGroup(tlsProtocol); opts.addOption("noclientauth", false, "disable client authentification for TLS"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default"); opts.addOption(OptionBuilder.create("keystore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for keystore file, 'secret' by default"); opts.addOption(OptionBuilder.create("keystorepw")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder .withDescription("password for accessing the key in the keystore, keystore password by default"); opts.addOption(OptionBuilder.create("keypw")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default"); opts.addOption(OptionBuilder.create("truststore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for truststore file, 'secret' by default"); opts.addOption(OptionBuilder.create("truststorepw")); OptionBuilder.withArgName("aet@host:port"); OptionBuilder.hasArg(); OptionBuilder.withDescription("request storage commitment of (successfully) sent objects " + "afterwards in new association to specified remote " + "Application Entity"); opts.addOption(OptionBuilder.create("stgcmtae")); opts.addOption("stgcmt", false, "request storage commitment of (successfully) sent objects " + "afterwards in same association"); OptionBuilder.withArgName("attr=value"); OptionBuilder.hasArgs(); OptionBuilder.withValueSeparator('='); OptionBuilder.withDescription("Replace value of specified attribute " + "with specified value in transmitted objects. attr can be " + "specified by name or tag value (in hex), e.g. PatientName " + "or 00100010."); opts.addOption(OptionBuilder.create("set")); OptionBuilder.withArgName("salt"); OptionBuilder.hasArgs(); OptionBuilder.withDescription( "Anonymize the files. Set to 0 for a random anonymization (not repeatable) or 1 for a daily anonymization or another" + " value for a specific salt for reproducible anonymization (useful for allowing studies to be sent at a later date and still correctly named/associated)"); OptionBuilder.withLongOpt("anonymize"); opts.addOption(OptionBuilder.create("a")); OptionBuilder.withArgName("sx1[:sx2[:sx3]"); OptionBuilder.hasArgs(); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription( "Suffix SOP [,Series [,Study]] " + "Instance UID with specified value[s] in transmitted objects."); opts.addOption(OptionBuilder.create("setuid")); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximum number of outstanding operations it may invoke " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("async")); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, " + "pack command and data PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default"); opts.addOption(OptionBuilder.create("connectTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, " + "50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for closing the listening socket, " + "1000ms by default"); opts.addOption(OptionBuilder.create("shutdowndelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, " + "10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("rspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default"); opts.addOption(OptionBuilder.create("acceptTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("transcoder buffer size in KB, 1KB by default"); opts.addOption(OptionBuilder.create("bufsize")); OptionBuilder.withArgName("count"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Batch size - Number of files to be sent in each batch, " + "where a storage commit is done between batches "); opts.addOption(OptionBuilder.create("batchsize")); opts.addOption("lowprior", false, "LOW priority of the C-STORE operation, MEDIUM by default"); opts.addOption("highprior", false, "HIGH priority of the C-STORE operation, MEDIUM by default"); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmsnd: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = DcmSnd.class.getPackage(); System.out.println("dcmsnd v" + p.getImplementationVersion()); // System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() < 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); // System.exit(0); } return cl; }
From source file:mod.org.dcm4che2.tool.DcmSnd.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();/*www. ja va 2s . c o m*/ OptionBuilder.withDescription("set device name, use DCMSND by default"); opts.addOption(OptionBuilder.create("device")); OptionBuilder.withArgName("aet[@host][:port]"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set AET, local address and listening port of local " + "Application Entity, use device name and pick up any valid " + "local address to bind the socket by default"); opts.addOption(OptionBuilder.create("L")); opts.addOption("ts1", false, "offer Default Transfer Syntax in " + "separate Presentation Context. By default offered with " + "Explicit VR Little Endian TS in one PC."); opts.addOption("fileref", false, "send objects without pixel data, but with a reference to " + "the DICOM file using DCM4CHE URI Referenced Transfer Syntax " + "to import DICOM objects on a given file system to a DCM4CHEE " + "archive."); OptionBuilder.withArgName("username"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "enable User Identity Negotiation with specified username and " + " optional passcode"); opts.addOption(OptionBuilder.create("username")); OptionBuilder.withArgName("passcode"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "optional passcode for User Identity Negotiation, " + "only effective with option -username"); opts.addOption(OptionBuilder.create("passcode")); opts.addOption("uidnegrsp", false, "request positive User Identity Negotation response, " + "only effective with option -username"); OptionBuilder.withArgName("NULL|3DES|AES"); OptionBuilder.hasArg(); OptionBuilder.withDescription("enable TLS connection without, 3DES or AES encryption"); opts.addOption(OptionBuilder.create("tls")); OptionGroup tlsProtocol = new OptionGroup(); tlsProtocol.addOption(new Option("tls1", "disable the use of SSLv3 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("ssl3", "disable the use of TLSv1 and SSLv2 for TLS connections")); tlsProtocol.addOption(new Option("no_tls1", "disable the use of TLSv1 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl3", "disable the use of SSLv3 for TLS connections")); tlsProtocol.addOption(new Option("no_ssl2", "disable the use of SSLv2 for TLS connections")); opts.addOptionGroup(tlsProtocol); opts.addOption("noclientauth", false, "disable client authentification for TLS"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder .withDescription("file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default"); opts.addOption(OptionBuilder.create("keystore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for keystore file, 'secret' by default"); opts.addOption(OptionBuilder.create("keystorepw")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder .withDescription("password for accessing the key in the keystore, keystore password by default"); opts.addOption(OptionBuilder.create("keypw")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default"); opts.addOption(OptionBuilder.create("truststore")); OptionBuilder.withArgName("password"); OptionBuilder.hasArg(); OptionBuilder.withDescription("password for truststore file, 'secret' by default"); opts.addOption(OptionBuilder.create("truststorepw")); OptionBuilder.withArgName("aet@host:port"); OptionBuilder.hasArg(); OptionBuilder.withDescription("request storage commitment of (successfully) sent objects " + "afterwards in new association to specified remote " + "Application Entity"); opts.addOption(OptionBuilder.create("stgcmtae")); opts.addOption("stgcmt", false, "request storage commitment of (successfully) sent objects " + "afterwards in same association"); OptionBuilder.withArgName("attr=value"); OptionBuilder.hasArgs(); OptionBuilder.withValueSeparator('='); OptionBuilder.withDescription("Replace value of specified attribute " + "with specified value in transmitted objects. attr can be " + "specified by name or tag value (in hex), e.g. PatientName " + "or 00100010."); opts.addOption(OptionBuilder.create("set")); OptionBuilder.withArgName("salt"); OptionBuilder.hasArgs(); OptionBuilder.withDescription( "Anonymize the files. Set to 0 for a random anonymization (not repeatable) or 1 for a daily anonymization or another" + " value for a specific salt for reproducible anonymization (useful for allowing studies to be sent at a later date and still correctly named/associated)"); OptionBuilder.withLongOpt("anonymize"); opts.addOption(OptionBuilder.create("a")); OptionBuilder.withArgName("sx1[:sx2[:sx3]"); OptionBuilder.hasArgs(); OptionBuilder.withValueSeparator(':'); OptionBuilder.withDescription( "Suffix SOP [,Series [,Study]] " + "Instance UID with specified value[s] in transmitted objects."); opts.addOption(OptionBuilder.create("setuid")); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximum number of outstanding operations it may invoke " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("async")); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, " + "pack command and data PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default"); opts.addOption(OptionBuilder.create("connectTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, " + "50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for closing the listening socket, " + "1000ms by default"); opts.addOption(OptionBuilder.create("shutdowndelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, " + "10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("rspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default"); opts.addOption(OptionBuilder.create("acceptTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("transcoder buffer size in KB, 1KB by default"); opts.addOption(OptionBuilder.create("bufsize")); OptionBuilder.withArgName("count"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Batch size - Number of files to be sent in each batch, " + "where a storage commit is done between batches "); opts.addOption(OptionBuilder.create("batchsize")); opts.addOption("lowprior", false, "LOW priority of the C-STORE operation, MEDIUM by default"); opts.addOption("highprior", false, "HIGH priority of the C-STORE operation, MEDIUM by default"); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmsnd: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = DcmSnd.class.getPackage(); System.out.println("dcmsnd v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() < 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }