List of usage examples for org.apache.commons.cli Options addOptionGroup
public Options addOptionGroup(OptionGroup group)
From source file:org.openrdf.console.Console.java
public static void main(final String[] args) throws IOException { final Console console = new Console(); final Option helpOption = new Option("h", "help", false, "print this help"); final Option versionOption = new Option("v", "version", false, "print version information"); final Option serverURLOption = new Option("s", "serverURL", true, "URL of Sesame server to connect to, e.g. http://localhost/openrdf-sesame/"); final Option dirOption = new Option("d", "dataDir", true, "Sesame data dir to 'connect' to"); Option echoOption = new Option("e", "echo", false, "echoes input back to stdout, useful for logging script sessions"); Option quietOption = new Option("q", "quiet", false, "suppresses prompts, useful for scripting"); Option forceOption = new Option("f", "force", false, "always answer yes to (suppressed) confirmation prompts"); Option cautiousOption = new Option("c", "cautious", false, "always answer no to (suppressed) confirmation prompts"); Option exitOnErrorMode = new Option("x", "exitOnError", false, "immediately exit the console on the first error"); final Options options = new Options(); OptionGroup cautionGroup = new OptionGroup().addOption(cautiousOption).addOption(forceOption) .addOption(exitOnErrorMode); OptionGroup locationGroup = new OptionGroup().addOption(serverURLOption).addOption(dirOption); options.addOptionGroup(locationGroup).addOptionGroup(cautionGroup); options.addOption(helpOption).addOption(versionOption).addOption(echoOption).addOption(quietOption); CommandLine commandLine = parseCommandLine(args, console, options); handleInfoOptions(console, helpOption, versionOption, options, commandLine); console.consoleIO.setEcho(commandLine.hasOption(echoOption.getOpt())); console.consoleIO.setQuiet(commandLine.hasOption(quietOption.getOpt())); exitOnError = commandLine.hasOption(exitOnErrorMode.getOpt()); String location = handleOptionGroups(console, serverURLOption, dirOption, forceOption, cautiousOption, options, cautionGroup, locationGroup, commandLine); final String[] otherArgs = commandLine.getArgs(); if (otherArgs.length > 1) { printUsage(console.consoleIO, options); System.exit(1);//from w ww. j a v a 2 s. c o m } connectAndOpen(console, locationGroup.getSelected(), location, otherArgs); console.start(); }
From source file:org.orbeon.oxf.main.SecureResource.java
private void parseArgs(String[] args) { Options options = new Options(); OptionGroup group = new OptionGroup(); group.addOption(new Option("e", "encrypt", false, "Encrypt")); group.addOption(new Option("d", "decrypt", false, "Decrypt")); group.addOption(new Option("v", "view", false, "View")); options.addOptionGroup(group); Option o = new Option("r", "root", true, "Resource Root"); o.setRequired(false);/* w w w . j a v a2 s .co m*/ options.addOption(o); options.addOption("a", "archive", true, "Archive Name"); try { CommandLine cmd = new PosixParser().parse(options, args, true); if (cmd.hasOption('e')) { mode = ENCRYPT_MODE; } else if (cmd.hasOption('d')) { mode = DECRYPT_MODE; } else if (cmd.hasOption('v')) { mode = VIEW_MODE; } resourceRoot = cmd.getOptionValue('r', "."); archiveName = cmd.getOptionValue('a'); } catch (MissingArgumentException e) { new HelpFormatter().printHelp("Missing argument", options); System.exit(1); } catch (UnrecognizedOptionException e) { new HelpFormatter().printHelp("Unrecognized option", options); System.exit(1); } catch (MissingOptionException e) { new HelpFormatter().printHelp("Missing option", options); System.exit(1); } catch (Exception e) { new HelpFormatter().printHelp("Unknown error", options); System.exit(1); } }
From source file:org.ow2.proactive.authentication.crypto.CreateCredentials.java
/** * Entry point/*from w w w . j a v a2 s.c om*/ * * @see org.ow2.proactive.authentication.crypto.Credentials * @param args arguments, try '-h' for help * @throws IOException * @throws ParseException * */ public static void main(String[] args) throws IOException, ParseException { SecurityManagerConfigurator.configureSecurityManager( CreateCredentials.class.getResource("/all-permissions.security.policy").toString()); Console console = System.console(); /** * default values */ boolean interactive = true; String pubKeyPath = null; PublicKey pubKey = null; String login = null; String pass = null; String keyfile = null; String cipher = "RSA/ECB/PKCS1Padding"; String path = Credentials.getCredentialsPath(); String rm = null; String scheduler = null; String url = null; Options options = new Options(); Option opt = new Option("h", "help", false, "Display this help"); opt.setRequired(false); options.addOption(opt); OptionGroup group = new OptionGroup(); group.setRequired(false); opt = new Option("F", "file", true, "Public key path on the local filesystem [default:" + Credentials.getPubKeyPath() + "]"); opt.setArgName("PATH"); opt.setArgs(1); opt.setRequired(false); group.addOption(opt); opt = new Option("R", "rm", true, "Request the public key to the Resource Manager at URL"); opt.setArgName("URL"); opt.setArgs(1); opt.setRequired(false); group.addOption(opt); opt = new Option("S", "scheduler", true, "Request the public key to the Scheduler at URL"); opt.setArgName("URL"); opt.setArgs(1); opt.setRequired(false); group.addOption(opt); options.addOptionGroup(group); opt = new Option("l", "login", true, "Generate credentials for this specific user, will be asked interactively if not specified"); opt.setArgName("LOGIN"); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option("p", "password", true, "Use this password, will be asked interactively if not specified"); opt.setArgName("PWD"); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option("k", "keyfile", true, "Use specified ssh private key, asked interactively if specified without PATH, not specified otherwise."); opt.setArgName("PATH"); opt.setOptionalArg(true); opt.setRequired(false); options.addOption(opt); opt = new Option("o", "output", true, "Output the resulting credentials to the specified file [default:" + path + "]"); opt.setArgName("PATH"); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option("c", "cipher", true, "Use specified cipher parameters, need to be compatible with the specified key [default:" + cipher + "]"); opt.setArgName("PARAMS"); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(newline + "ERROR : " + e.getMessage() + newline); System.out.println("type -h or --help to display help screen"); System.exit(1); } if (cmd.hasOption("help")) { displayHelp(options); } if (cmd.hasOption("file")) { pubKeyPath = cmd.getOptionValue("file"); } if (cmd.hasOption("rm")) { rm = cmd.getOptionValue("rm"); } if (cmd.hasOption("scheduler")) { scheduler = cmd.getOptionValue("scheduler"); } if (cmd.hasOption("login")) { login = cmd.getOptionValue("login"); } if (cmd.hasOption("password")) { pass = cmd.getOptionValue("password"); } if (cmd.hasOption("keyfile") && cmd.getOptionValues("keyfile") != null) { keyfile = cmd.getOptionValue("keyfile"); } if (cmd.hasOption("output")) { path = cmd.getOptionValue("output"); } if (cmd.hasOption("cipher")) { cipher = cmd.getOptionValue("cipher"); } int acc = 0; if (pubKeyPath != null) { acc++; } if (scheduler != null) { url = Connection.normalize(scheduler) + "SCHEDULER"; acc++; } if (rm != null) { url = Connection.normalize(rm) + "RMAUTHENTICATION"; acc++; } if (acc > 1) { System.out.println("--rm, --scheduler and --file arguments cannot be combined."); System.out.println("try -h for help."); System.exit(1); } if (url != null) { try { Connection<AuthenticationImpl> conn = new Connection<AuthenticationImpl>(AuthenticationImpl.class) { public Logger getLogger() { return Logger.getLogger("pa.scheduler.credentials"); } }; AuthenticationImpl auth = conn.connect(url); pubKey = auth.getPublicKey(); } catch (Exception e) { System.err.println("ERROR : Could not retrieve public key from '" + url + "'"); e.printStackTrace(); System.exit(3); } System.out.println("Successfully obtained public key from " + url + newline); } else if (pubKeyPath != null) { try { pubKey = Credentials.getPublicKey(pubKeyPath); } catch (KeyException e) { System.err .println("ERROR : Could not retrieve public key from '" + pubKeyPath + "' (no such file)"); System.exit(4); } } else { System.out.println("No public key specified, attempting to retrieve it from default location."); pubKeyPath = Credentials.getPubKeyPath(); try { pubKey = Credentials.getPublicKey(pubKeyPath); } catch (KeyException e) { System.err .println("ERROR : Could not retrieve public key from '" + pubKeyPath + "' (no such file)"); System.exit(5); } } if (login != null && pass != null && (!cmd.hasOption("keyfile") || cmd.getOptionValues("keyfile") != null)) { System.out.println("Running in non-interactive mode." + newline); interactive = false; } else { System.out.println("Running in interactive mode."); } if (interactive) { System.out.println("Please enter Scheduler credentials,"); System.out.println("they will be stored encrypted on disk for future logins." + newline); System.out.print("login: "); if (login == null) { login = console.readLine(); } else { System.out.println(login); } System.out.print("password: "); if (pass == null) { pass = new String(console.readPassword()); } else { System.out.println("*******"); } System.out.print("keyfile: "); if (!cmd.hasOption("keyfile")) { System.out.println("no key file specified"); } else if (cmd.hasOption("keyfile") && cmd.getOptionValues("keyfile") != null) { System.out.println(keyfile); } else { keyfile = console.readLine(); } } try { CredData credData; if (keyfile != null && keyfile.length() > 0) { byte[] keyfileContent = FileToBytesConverter.convertFileToByteArray(new File(keyfile)); credData = new CredData(CredData.parseLogin(login), CredData.parseDomain(login), pass, keyfileContent); } else { System.out.println("--> Ignoring keyfile, credential does not contain SSH key"); credData = new CredData(CredData.parseLogin(login), CredData.parseDomain(login), pass); } Credentials cred = Credentials.createCredentials(credData, pubKey, cipher); cred.writeToDisk(path); } catch (FileNotFoundException e) { System.err.println("ERROR : Could not retrieve ssh private key from '" + keyfile + "' (no such file)"); System.exit(6); } catch (Throwable t) { t.printStackTrace(); System.exit(7); } System.out.println("Successfully stored encrypted credentials on disk at :"); System.out.println("\t" + path); System.exit(0); }
From source file:org.ow2.proactive.resourcemanager.utils.console.ResourceManagerController.java
protected OptionGroup addCommandLineOptions(Options options) { OptionGroup actionGroup = new OptionGroup(); Option addNodesOpt = new Option("a", "addnodes", true, control + "Add nodes by their URLs"); addNodesOpt.setArgName("node URLs"); addNodesOpt.setRequired(false);//from ww w . jav a 2 s . co m addNodesOpt.setArgs(Option.UNLIMITED_VALUES); actionGroup.addOption(addNodesOpt); Option removeNodesOpt = new Option("d", "removenodes", true, control + "Remove nodes by their URLs"); removeNodesOpt.setArgName("node URLs"); removeNodesOpt.setRequired(false); removeNodesOpt.setArgs(Option.UNLIMITED_VALUES); actionGroup.addOption(removeNodesOpt); Option lockNodesOpt = new Option("locknodes", true, control + "Lock nodes by their URLs"); lockNodesOpt.setArgName("node URLs"); lockNodesOpt.setRequired(false); lockNodesOpt.setArgs(Option.UNLIMITED_VALUES); actionGroup.addOption(lockNodesOpt); Option unlockNodesOpt = new Option("unlocknodes", true, control + "Unlock nodes by their URLs"); unlockNodesOpt.setArgName("node URLs"); unlockNodesOpt.setRequired(false); unlockNodesOpt.setArgs(Option.UNLIMITED_VALUES); actionGroup.addOption(unlockNodesOpt); Option createNSOpt = new Option("cn", "createns", true, control + "Create new node sources"); createNSOpt.setArgName("names"); createNSOpt.setRequired(false); createNSOpt.setArgs(Option.UNLIMITED_VALUES); actionGroup.addOption(createNSOpt); Option infrastuctureOpt = new Option("i", "infrastructure", true, "Specify an infrastructure when node source is created"); infrastuctureOpt.setArgName("params"); infrastuctureOpt.setRequired(false); infrastuctureOpt.setOptionalArg(true); infrastuctureOpt.setArgs(Option.UNLIMITED_VALUES); options.addOption(infrastuctureOpt); Option policyOpt = new Option("p", "policy", true, "Specify a policy when node source is created"); policyOpt.setArgName("params"); policyOpt.setOptionalArg(true); policyOpt.setRequired(false); policyOpt.setArgs(Option.UNLIMITED_VALUES); options.addOption(policyOpt); Option listNodesOpt = new Option("ln", "listnodes", true, control + "List nodes handled by Resource Manager. Display is : NODESOURCE HOSTNAME STATE NODE_URL"); listNodesOpt.setRequired(false); listNodesOpt.setOptionalArg(true); listNodesOpt.setArgName("nodeSourceName"); actionGroup.addOption(listNodesOpt); Option listNSOpt = new Option("lns", "listns", false, control + "List node sources on Resource Manager. Display is : NODESOURCE TYPE"); listNSOpt.setRequired(false); actionGroup.addOption(listNSOpt); Option topologyOpt = new Option("t", "topology", false, control + "Displays nodes topology."); topologyOpt.setRequired(false); actionGroup.addOption(topologyOpt); Option removeNSOpt = new Option("r", "removens", true, control + "Remove given node sources"); removeNSOpt.setArgName("names"); removeNSOpt.setRequired(false); removeNSOpt.setArgs(Option.UNLIMITED_VALUES); actionGroup.addOption(removeNSOpt); Option shutdownOpt = new Option("s", "shutdown", false, control + "Shutdown Resource Manager"); shutdownOpt.setRequired(false); actionGroup.addOption(shutdownOpt); Option acopt = new Option("stats", "statistics", false, control + "Display some statistics about the Resource Manager"); acopt.setRequired(false); acopt.setArgs(0); actionGroup.addOption(acopt); acopt = new Option("ma", "myaccount", false, control + "Display current user account informations"); acopt.setRequired(false); acopt.setArgs(0); actionGroup.addOption(acopt); acopt = new Option("ua", "useraccount", false, control + "Display account information by username"); acopt.setRequired(false); acopt.setArgs(1); acopt.setArgName("username"); actionGroup.addOption(acopt); acopt = new Option("ni", "nodeinfo", true, control + "Display node information"); acopt.setRequired(false); acopt.setArgs(1); acopt.setArgName("nodeURL"); actionGroup.addOption(acopt); acopt = new Option("rc", "reloadconfig", false, control + "Reloads the resource manager permission policy and log4j config"); acopt.setRequired(false); acopt.setArgs(0); actionGroup.addOption(acopt); options.addOptionGroup(actionGroup); Option nodeSourceNameOpt = new Option("ns", "nodesource", true, control + "Specify an existing node source name for adding nodes"); nodeSourceNameOpt.setArgName("nodes URLs"); nodeSourceNameOpt.setRequired(false); nodeSourceNameOpt.setArgs(1); options.addOption(nodeSourceNameOpt); Option preeemptiveRemovalOpt = new Option("f", "force", false, control + "Do not wait for busy nodes to be freed before " + "nodes removal, node source removal and shutdown actions (-d, -r and -s)"); preeemptiveRemovalOpt.setRequired(false); options.addOption(preeemptiveRemovalOpt); Option script = new Option("sf", "script", true, control + "Execute the given javascript file with optional arguments."); script.setArgName("filePath arg1=val1 arg2=val2 ..."); script.setArgs(Option.UNLIMITED_VALUES); script.setOptionalArg(true); script.setRequired(false); options.addOption(script); script = new Option("env", "environment", true, "Execute the given script and go into interactive mode"); script.setArgName("filePath"); script.setRequired(false); script.setOptionalArg(true); options.addOption(script); Option opt = new Option("c", "credentials", true, "Path to the credentials (" + Credentials.getCredentialsPath() + ")."); opt.setRequired(false); opt.setArgs(1); options.addOption(opt); return actionGroup; }
From source file:org.ow2.proactive.scheduler.authentication.ManageUsers.java
/** * Build the command line options and parse *//*from ww w .ja v a 2 s. co m*/ private static CommandLine getCommandLine(String[] args, String loginFilePath, String groupFilePath, Options options) throws ManageUsersException { Option opt = new Option(HELP_OPTION, HELP_OPTION_NAME, false, "Display this help"); opt.setRequired(false); options.addOption(opt); OptionGroup optionGroup = new OptionGroup(); optionGroup.setRequired(false); opt = new Option(CREATE_OPTION, CREATE_OPTION_NAME, true, "Action to create a user"); opt.setArgName(CREATE_OPTION_NAME.toUpperCase()); opt.setArgs(0); opt.setRequired(false); optionGroup.addOption(opt); opt = new Option(UPDATE_OPTION, UPDATE_OPTION_NAME, true, "Action to update an existing user. Updating a user means to change the user's password or group membership."); opt.setArgName(UPDATE_OPTION_NAME.toUpperCase()); opt.setArgs(0); opt.setRequired(false); optionGroup.addOption(opt); opt = new Option(DELETE_OPTION, DELETE_OPTION_NAME, true, "Action to delete an existing user"); opt.setArgName(DELETE_OPTION_NAME.toUpperCase()); opt.setArgs(0); opt.setRequired(false); optionGroup.addOption(opt); options.addOptionGroup(optionGroup); opt = new Option(LOGIN_OPTION, LOGIN_OPTION_NAME, true, "Generate credentials for this specific user, will be asked interactively if not specified"); opt.setArgName(LOGIN_OPTION_NAME.toUpperCase()); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option(PWD_OPTION, PWD_OPTION_NAME, true, "Password of the user, if the user is created or updated, will be asked interactively if not specified"); opt.setArgName(PWD_OPTION_NAME.toUpperCase()); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option(GROUPS_OPTION, GROUPS_OPTION_NAME, true, "A comma-separated list of groups the user must be member of. Can be used when the user is created or updated"); opt.setArgName(GROUPS_OPTION_NAME.toUpperCase()); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); optionGroup.setRequired(false); opt = new Option(KEYFILE_OPTION, KEYFILE_OPTION_NAME, true, "Public key path on the local filesystem [default:" + getPublicKeyFilePath() + "]"); opt.setArgName(KEYFILE_OPTION_NAME.toUpperCase()); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option(LOGINFILE_OPTION, LOGINFILE_OPTION_NAME, true, "Path to the login file in use [default:" + loginFilePath + "]"); opt.setArgName(LOGINFILE_OPTION_NAME.toUpperCase()); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option(GROUPFILE_OPTION, GROUPFILE_OPTION_NAME, true, "Path to the group file in use [default:" + groupFilePath + "]"); opt.setArgName(GROUPFILE_OPTION_NAME.toUpperCase()); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option(SOURCE_LOGINFILE_OPTION, SOURCE_LOGINFILE_OPTION_NAME, true, "Path to a source login file, used for bulk creation or bulk update. The source login file must contain clear text passwords in the format username:password"); opt.setArgName(SOURCE_LOGINFILE_OPTION_NAME.toUpperCase()); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); opt = new Option(SOURCE_GROUPFILE_OPTION, SOURCE_GROUPFILE_OPTION_NAME, true, "Path to a source group file, used for bulk creation or bulk update. The source group file must contain group assignements in the format username:group"); opt.setArgName(SOURCE_GROUPFILE_OPTION_NAME.toUpperCase()); opt.setArgs(1); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { exitWithErrorMessage(newline + e.getMessage() + newline, "type -h or --help to display help screen", null); } return cmd; }
From source file:org.ow2.proactive.scheduler.util.console.SchedulerController.java
protected OptionGroup addCommandLineOptions(Options options) { OptionGroup actionGroup = new OptionGroup(); Option opt = new Option("s", "submit", true, control + "Submit the given job XML file"); opt.setArgName("XMLDescriptor"); opt.setRequired(false);/*from w ww. ja v a 2 s . co m*/ opt.setArgs(Option.UNLIMITED_VALUES); actionGroup.addOption(opt); opt = new Option("sa", "submitarchive", true, control + "Submit the given job archive"); opt.setArgName("jobarchive"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("cmd", "command", false, control + "If mentionned, -submit argument becomes a command line, ie: -submit command args..."); opt.setRequired(false); options.addOption(opt); opt = new Option("cmdf", "commandf", false, control + "If mentionned, -submit argument becomes a text file path containing command lines to schedule"); opt.setRequired(false); options.addOption(opt); opt = new Option("ss", "selectscript", true, control + "Used with -cmd or -cmdf, specify a selection script"); opt.setArgName("selectScript"); opt.setRequired(false); opt.setArgs(1); options.addOption(opt); opt = new Option("jn", "jobname", true, control + "Used with -cmd or -cmdf, specify the job name"); opt.setArgName("jobName"); opt.setRequired(false); opt.setArgs(1); options.addOption(opt); opt = new Option("pj", "pausejob", true, control + "Pause the given job (pause every non-running tasks)"); opt.setArgName("jobId"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("rj", "resumejob", true, control + "Resume the given job (restart every paused tasks)"); opt.setArgName("jobId"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("kj", "killjob", true, control + "Kill the given job (cause the job to finish)"); opt.setArgName("jobId"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("rmj", "removejob", true, control + "Remove the given job"); opt.setArgName("jobId"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("pt", "preempttask", true, control + "Stop the given task and re-schedules it after specified delay."); opt.setArgName("jobId taskName delay"); opt.setRequired(false); opt.setArgs(3); actionGroup.addOption(opt); opt = new Option("rt", "restarttask", true, control + "Terminate the given task and re-schedules it after specified delay."); opt.setArgName("jobId taskName delay"); opt.setRequired(false); opt.setArgs(3); actionGroup.addOption(opt); opt = new Option("kt", "killtask", true, control + "Kill the given task."); opt.setArgName("jobId taskName"); opt.setRequired(false); opt.setArgs(2); actionGroup.addOption(opt); opt = new Option("jr", "jobresult", true, control + "Get the result of the given job"); opt.setArgName("jobId"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("tr", "taskresult", true, control + "Get the result of the given task"); opt.setArgName("jobId taskName [inc]"); opt.setRequired(false); opt.setArgs(3); opt.setOptionalArg(true); actionGroup.addOption(opt); opt = new Option("jo", "joboutput", true, control + "Get the output of the given job"); opt.setArgName("jobId"); opt.setRequired(false); opt.setArgs(2); actionGroup.addOption(opt); opt = new Option("to", "taskoutput", true, control + "Get the output of the given task"); opt.setArgName("jobId taskName"); opt.setRequired(false); opt.setArgs(2); actionGroup.addOption(opt); opt = new Option("jp", "jobpriority", true, control + "Change the priority of the given job (Idle, Lowest, Low, Normal, High, Highest)"); opt.setArgName("jobId newPriority"); opt.setRequired(false); opt.setArgs(2); actionGroup.addOption(opt); opt = new Option("js", "jobstate", true, control + "Get the current state of the given job (Also tasks description)"); opt.setArgName("jobId"); opt.setRequired(false); opt.setArgs(2); actionGroup.addOption(opt); opt = new Option("lj", "listjobs", false, control + "Display the list of jobs managed by the scheduler"); opt.setRequired(false); opt.setArgs(0); actionGroup.addOption(opt); opt = new Option("stats", "statistics", false, control + "Display some statistics about the Scheduler"); opt.setRequired(false); opt.setArgs(0); actionGroup.addOption(opt); opt = new Option("ma", "myaccount", false, control + "Display current user account information"); opt.setRequired(false); opt.setArgs(0); actionGroup.addOption(opt); opt = new Option("ua", "useraccount", false, control + "Display account information by username"); opt.setRequired(false); opt.setArgs(1); opt.setArgName("username"); actionGroup.addOption(opt); opt = new Option("rc", "reloadconfig", false, control + "Reloads the scheduler permission policy and log4j config"); opt.setRequired(false); opt.setArgs(0); actionGroup.addOption(opt); opt = new Option("sf", "script", true, control + "Execute the given javascript file with optional arguments."); opt.setArgName("filePath arg1=val1 arg2=val2 ..."); opt.setRequired(false); opt.setArgs(Option.UNLIMITED_VALUES); opt.setOptionalArg(true); actionGroup.addOption(opt); opt = new Option("env", "environment", true, "Execute the given script as an environment for the interactive mode"); opt.setArgName("filePath"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("test", false, control + "Test if the Scheduler is successfully started by committing some examples"); opt.setRequired(false); opt.setArgs(0); actionGroup.addOption(opt); opt = new Option("c", "credentials", true, "Path to the credentials (" + Credentials.getCredentialsPath() + ")."); opt.setRequired(false); opt.setOptionalArg(true); options.addOption(opt); options.addOptionGroup(actionGroup); opt = new Option("start", "schedulerstart", false, control + "Start the Scheduler"); opt.setRequired(false); actionGroup.addOption(opt); opt = new Option("stop", "schedulerstop", false, control + "Stop the Scheduler"); opt.setRequired(false); actionGroup.addOption(opt); opt = new Option("pause", "schedulerpause", false, control + "Pause the Scheduler (cause all non-running jobs to be paused)"); opt.setRequired(false); actionGroup.addOption(opt); opt = new Option("freeze", "schedulerfreeze", false, control + "Freeze the Scheduler (cause all non-running tasks to be paused)"); opt.setRequired(false); actionGroup.addOption(opt); opt = new Option("resume", "schedulerresume", false, control + "Resume the Scheduler"); opt.setRequired(false); actionGroup.addOption(opt); opt = new Option("shutdown", "schedulershutdown", false, control + "Shutdown the Scheduler"); opt.setRequired(false); actionGroup.addOption(opt); opt = new Option("kill", "schedulerkill", false, control + "Kill the Scheduler"); opt.setRequired(false); actionGroup.addOption(opt); opt = new Option("lrm", "linkrm", true, control + "Reconnect a RM to the scheduler"); opt.setArgName("rmURL"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("pr", "policyreload", false, control + "Reload the policy configuration"); opt.setRequired(false); actionGroup.addOption(opt); opt = new Option("p", "policy", true, control + "Change the current scheduling policy"); opt.setArgName("fullName"); opt.setRequired(false); opt.setArgs(1); actionGroup.addOption(opt); opt = new Option("ll", "logs", true, control + "Get server logs of given job or task"); opt.setArgName("jobId [taskName]"); opt.setRequired(false); opt.setArgs(2); actionGroup.addOption(opt); options.addOptionGroup(actionGroup); return actionGroup; }
From source file:org.owasp.dependencycheck.cli.CliParser.java
/** * Adds the standard command line options to the given options collection. * * @param options a collection of command line arguments * @throws IllegalArgumentException thrown if there is an exception *///from w ww.ja v a2s . com @SuppressWarnings("static-access") private void addStandardOptions(final Options options) throws IllegalArgumentException { final Option help = new Option(ArgumentName.HELP_SHORT, ArgumentName.HELP, false, "Print this message."); final Option advancedHelp = OptionBuilder.withLongOpt(ArgumentName.ADVANCED_HELP) .withDescription("Print the advanced help message.").create(); final Option version = new Option(ArgumentName.VERSION_SHORT, ArgumentName.VERSION, false, "Print the version information."); final Option noUpdate = new Option(ArgumentName.DISABLE_AUTO_UPDATE_SHORT, ArgumentName.DISABLE_AUTO_UPDATE, false, "Disables the automatic updating of the CPE data."); final Option appName = OptionBuilder.withArgName("name").hasArg().withLongOpt(ArgumentName.APP_NAME) .withDescription("The name of the application being scanned. This is a required argument.") .create(ArgumentName.APP_NAME_SHORT); final Option path = OptionBuilder.withArgName("path").hasArg().withLongOpt(ArgumentName.SCAN) .withDescription("The path to scan - this option can be specified multiple times. To limit the scan" + " to specific file types *.[ext] can be added to the end of the path.") .create(ArgumentName.SCAN_SHORT); final Option props = OptionBuilder.withArgName("file").hasArg().withLongOpt(ArgumentName.PROP) .withDescription("A property file to load.").create(ArgumentName.PROP_SHORT); final Option out = OptionBuilder.withArgName("folder").hasArg().withLongOpt(ArgumentName.OUT) .withDescription("The folder to write reports to. This defaults to the current directory.") .create(ArgumentName.OUT_SHORT); final Option outputFormat = OptionBuilder.withArgName("format").hasArg() .withLongOpt(ArgumentName.OUTPUT_FORMAT) .withDescription("The output format to write to (XML, HTML, VULN, ALL). The default is HTML.") .create(ArgumentName.OUTPUT_FORMAT_SHORT); final Option verboseLog = OptionBuilder.withArgName("file").hasArg().withLongOpt(ArgumentName.VERBOSE_LOG) .withDescription("The file path to write verbose logging information.") .create(ArgumentName.VERBOSE_LOG_SHORT); final Option suppressionFile = OptionBuilder.withArgName("file").hasArg() .withLongOpt(ArgumentName.SUPPRESSION_FILE) .withDescription("The file path to the suppression XML file.").create(); //This is an option group because it can be specified more then once. final OptionGroup og = new OptionGroup(); og.addOption(path); options.addOptionGroup(og).addOption(out).addOption(outputFormat).addOption(appName).addOption(version) .addOption(help).addOption(advancedHelp).addOption(noUpdate).addOption(props).addOption(verboseLog) .addOption(suppressionFile); }
From source file:org.owasp.dependencycheck.CliParser.java
/** * Adds the standard command line options to the given options collection. * * @param options a collection of command line arguments * @throws IllegalArgumentException thrown if there is an exception *//* w w w . ja va 2 s. c o m*/ @SuppressWarnings("static-access") private void addStandardOptions(final Options options) throws IllegalArgumentException { final Option help = new Option(ARGUMENT.HELP_SHORT, ARGUMENT.HELP, false, "Print this message."); final Option advancedHelp = Option.builder().longOpt(ARGUMENT.ADVANCED_HELP) .desc("Print the advanced help message.").build(); final Option version = new Option(ARGUMENT.VERSION_SHORT, ARGUMENT.VERSION, false, "Print the version information."); final Option noUpdate = new Option(ARGUMENT.DISABLE_AUTO_UPDATE_SHORT, ARGUMENT.DISABLE_AUTO_UPDATE, false, "Disables the automatic updating of the CPE data."); final Option projectName = Option.builder().hasArg().argName("name").longOpt(ARGUMENT.PROJECT) .desc("The name of the project being scanned. This is a required argument.").build(); final Option path = Option.builder(ARGUMENT.SCAN_SHORT).argName("path").hasArg().longOpt(ARGUMENT.SCAN) .desc("The path to scan - this option can be specified multiple times. Ant style" + " paths are supported (e.g. path/**/*.jar).") .build(); final Option excludes = Option.builder().argName("pattern").hasArg().longOpt(ARGUMENT.EXCLUDE) .desc("Specify and exclusion pattern. This option can be specified multiple times" + " and it accepts Ant style excludsions.") .build(); final Option props = Option.builder(ARGUMENT.PROP_SHORT).argName("file").hasArg().longOpt(ARGUMENT.PROP) .desc("A property file to load.").build(); final Option out = Option.builder(ARGUMENT.OUT_SHORT).argName("path").hasArg().longOpt(ARGUMENT.OUT) .desc("The folder to write reports to. This defaults to the current directory. " + "It is possible to set this to a specific file name if the format argument is not set to ALL.") .build(); final Option outputFormat = Option.builder(ARGUMENT.OUTPUT_FORMAT_SHORT).argName("format").hasArg() .longOpt(ARGUMENT.OUTPUT_FORMAT) .desc("The output format to write to (XML, HTML, VULN, ALL). The default is HTML.").build(); final Option verboseLog = Option.builder(ARGUMENT.VERBOSE_LOG_SHORT).argName("file").hasArg() .longOpt(ARGUMENT.VERBOSE_LOG).desc("The file path to write verbose logging information.").build(); final Option symLinkDepth = Option.builder().argName("depth").hasArg().longOpt(ARGUMENT.SYM_LINK_DEPTH) .desc("Sets how deep nested symbolic links will be followed; 0 indicates symbolic links will not be followed.") .build(); final Option suppressionFile = Option.builder().argName("file").hasArg().longOpt(ARGUMENT.SUPPRESSION_FILE) .desc("The file path to the suppression XML file.").build(); final Option cveValidForHours = Option.builder().argName("hours").hasArg() .longOpt(ARGUMENT.CVE_VALID_FOR_HOURS) .desc("The number of hours to wait before checking for new updates from the NVD.").build(); final Option experimentalEnabled = Option.builder().longOpt(ARGUMENT.EXPERIMENTAL) .desc("Enables the experimental analzers.").build(); //This is an option group because it can be specified more then once. final OptionGroup og = new OptionGroup(); og.addOption(path); final OptionGroup exog = new OptionGroup(); exog.addOption(excludes); options.addOptionGroup(og).addOptionGroup(exog).addOption(projectName).addOption(out) .addOption(outputFormat).addOption(version).addOption(help).addOption(advancedHelp) .addOption(noUpdate).addOption(symLinkDepth).addOption(props).addOption(verboseLog) .addOption(suppressionFile).addOption(cveValidForHours).addOption(experimentalEnabled); }
From source file:org.psystems.dicom.daemon.Archive.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();/*from ww w .j av a 2 s . co m*/ OptionBuilder.withDescription("set device name, use DCMRCV by default"); opts.addOption(OptionBuilder.create("device")); 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("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("store received objects into files in specified directory <dir>." + " Do not store received objects by default."); opts.addOption(OptionBuilder.create("dest")); OptionBuilder.withArgName("URL"); OptionBuilder.hasArg(); OptionBuilder.withDescription("jdbc connect <URL>.\n example: " + Extractor.connectionStr); opts.addOption(OptionBuilder.create("jdbcconnect")); OptionBuilder.withArgName("config"); OptionBuilder.hasArg(); OptionBuilder.withDescription("config file <config> .\n example: " + Extractor.configStr); opts.addOption(OptionBuilder.create("config")); opts.addOption("startdb", false, "Start 'Derby Network Server' set JavaVM Args: -Dderby.system.home=dtabase/instance -Dderby.drda.startNetworkServer=true -Dderby.drda.portNumber=1527 -Dderby.drda.host=localhost"); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of properties for mapping Calling AETs to " + "sub-directories of the storage directory specified by " + "-dest, to separate the storage location dependend on " + "Calling AETs."); opts.addOption(OptionBuilder.create("calling2dir")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of properties for mapping Called AETs to " + "sub-directories of the storage directory specified by " + "-dest, to separate the storage location dependend on " + "Called AETs."); opts.addOption(OptionBuilder.create("called2dir")); OptionBuilder.withArgName("sub-dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("storage sub-directory used for Calling AETs for which no " + " mapping is defined by properties specified by " + "-calling2dir, 'OTHER' by default."); opts.addOption(OptionBuilder.create("callingdefdir")); OptionBuilder.withArgName("sub-dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("storage sub-directory used for Called AETs for which no " + " mapping is defined by properties specified by " + "-called2dir, 'OTHER' by default."); opts.addOption(OptionBuilder.create("calleddefdir")); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("register stored objects in cache journal files in specified directory <dir>." + " Do not register stored objects by default."); opts.addOption(OptionBuilder.create("journal")); OptionBuilder.withArgName("pattern"); OptionBuilder.hasArg(); OptionBuilder.withDescription("cache journal file path, with " + "'yyyy' will be replaced by the current year, " + "'MM' by the current month, 'dd' by the current date, " + "'HH' by the current hour and 'mm' by the current minute. " + "'yyyy/MM/dd/HH/mm' by default."); opts.addOption(OptionBuilder.create("journalfilepath")); opts.addOption("defts", false, "accept only default transfer syntax."); opts.addOption("bigendian", false, "accept also Explict VR Big Endian transfer syntax."); opts.addOption("native", false, "accept only transfer syntax with uncompressed pixel data."); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "maximum number of outstanding operations performed " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("async")); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, " + "pack command and data PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, 50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for DIMSE-RSP; useful for testing asynchronous mode"); opts.addOption(OptionBuilder.create("rspdelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving -ASSOCIATE-RQ, 5s by default"); opts.addOption(OptionBuilder.create("requestTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RQ, 60s by default"); opts.addOption(OptionBuilder.create("idleTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("minimal buffer size to write received object to file, 1KB by default"); opts.addOption(OptionBuilder.create("bufsize")); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmarchive: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption("V")) { Package p = Archive.class.getPackage(); System.out.println("dcmarchive v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption("h")/* || cl.getArgList().size() == 0*/) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:org.psystems.dicom.daemon.DcmRcvOriginal.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();/*ww w. ja v a 2 s . c o m*/ OptionBuilder.withDescription("set device name, use DCMRCV by default"); opts.addOption(OptionBuilder.create("device")); 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("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("store received objects into files in specified directory <dir>." + " Do not store received objects by default."); opts.addOption(OptionBuilder.create("dest")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of properties for mapping Calling AETs to " + "sub-directories of the storage directory specified by " + "-dest, to separate the storage location dependend on " + "Calling AETs."); opts.addOption(OptionBuilder.create("calling2dir")); OptionBuilder.withArgName("file|url"); OptionBuilder.hasArg(); OptionBuilder.withDescription("file path or URL of properties for mapping Called AETs to " + "sub-directories of the storage directory specified by " + "-dest, to separate the storage location dependend on " + "Called AETs."); opts.addOption(OptionBuilder.create("called2dir")); OptionBuilder.withArgName("sub-dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("storage sub-directory used for Calling AETs for which no " + " mapping is defined by properties specified by " + "-calling2dir, 'OTHER' by default."); opts.addOption(OptionBuilder.create("callingdefdir")); OptionBuilder.withArgName("sub-dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("storage sub-directory used for Called AETs for which no " + " mapping is defined by properties specified by " + "-called2dir, 'OTHER' by default."); opts.addOption(OptionBuilder.create("calleddefdir")); OptionBuilder.withArgName("dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("register stored objects in cache journal files in specified directory <dir>." + " Do not register stored objects by default."); opts.addOption(OptionBuilder.create("journal")); OptionBuilder.withArgName("pattern"); OptionBuilder.hasArg(); OptionBuilder.withDescription("cache journal file path, with " + "'yyyy' will be replaced by the current year, " + "'MM' by the current month, 'dd' by the current date, " + "'HH' by the current hour and 'mm' by the current minute. " + "'yyyy/MM/dd/HH/mm' by default."); opts.addOption(OptionBuilder.create("journalfilepath")); opts.addOption("defts", false, "accept only default transfer syntax."); opts.addOption("bigendian", false, "accept also Explict VR Big Endian transfer syntax."); opts.addOption("native", false, "accept only transfer syntax with uncompressed pixel data."); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "maximum number of outstanding operations performed " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("async")); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, " + "pack command and data PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, 50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for DIMSE-RSP; useful for testing asynchronous mode"); opts.addOption(OptionBuilder.create("rspdelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving -ASSOCIATE-RQ, 5s by default"); opts.addOption(OptionBuilder.create("requestTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RQ, 60s by default"); opts.addOption(OptionBuilder.create("idleTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("minimal buffer size to write received object to file, 1KB by default"); opts.addOption(OptionBuilder.create("bufsize")); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmrcv: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption("V")) { Package p = DcmRcvOriginal.class.getPackage(); System.out.println("dcmrcv v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption("h") || cl.getArgList().size() == 0) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }