List of usage examples for org.apache.commons.cli CommandLine getArgList
public List getArgList()
From source file:br.usp.poli.lta.cereda.macro.util.CLIParser.java
/** * Realiza a anlise dos argumentos de linha de comando e retorna um par * contendo o texto a ser expandido e o arquivo de sada. * @return Um par contendo o texto a ser expandido e o arquivo de sada. * @throws IOException Um dos arquivos de entrada no existe. *///from w w w .j a v a2s .c om public Pair<String, File> parse() throws IOException { // opo de entrada Option input = OptionBuilder.withLongOpt("input").hasArgs().withArgName("lista de arquivos") .withDescription("arquivos de entrada").create("i"); // opo de sada Option output = OptionBuilder.withLongOpt("output").hasArg().withArgName("arquivo") .withDescription("arquivo de sada").create("o"); // opo do editor embutido Option ui = OptionBuilder.withLongOpt("editor").withDescription("editor grfico").create("e"); Options options = new Options(); options.addOption(input); options.addOption(output); options.addOption(ui); try { // parsing dos argumentos Parser parser = new BasicParser(); CommandLine line = parser.parse(options, arguments); // verifica se uma chamada ao editor e retorna em caso positivo if (line.hasOption("e")) { editor = true; return null; } // se no uma chamada ao editor de macros, necessrio verificar // se existe um arquivo de entrada if (!line.hasOption("i")) { throw new ParseException(""); } // existem argumentos restantes, o que representa situao de erro if (!line.getArgList().isEmpty()) { throw new ParseException(""); } String text = ""; File out = line.hasOption("output") ? new File(line.getOptionValue("output")) : null; if (out == null) { logger.info("A sada ser gerada no terminal."); } else { logger.info("A sada ser gerada no arquivo '{}'.", out.getName()); } // faz a leitura de todos os arquivos e concatena seu contedo em // uma varivel logger.info("Iniciando a leitura dos arquivos de entrada."); String[] files = line.getOptionValues("input"); for (String file : files) { logger.info("Lendo arquivo '{}'.", file); text = text.concat(FileUtils.readFileToString(new File(file), Charset.forName("UTF-8"))); } // retorna o par da varivel contendo o texto de todos os arquivos // e a referncia ao arquivo de sada (podendo este ser nulo) return new Pair<>(text, out); } catch (ParseException exception) { // imprime a ajuda HelpFormatter help = new HelpFormatter(); help.printHelp("expander ( --editor | --input <lista de arquivos>" + " [ --output <arquivo> ] )", options); } // retorna um valor invlido indicando para no prosseguir com o // processo de expanso return null; }
From source file:daemon.dicomnode.DcmRcv.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();//from w w w . j a va 2 s . com 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."); OptionGroup scRetrieveAET = new OptionGroup(); OptionBuilder.withArgName("aet"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Retrieve AE Title included in Storage Commitment " + "N-EVENT-REPORT in items of the Referenced SOP Sequence."); scRetrieveAET.addOption(OptionBuilder.create("scretraets")); OptionBuilder.withArgName("aet"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Retrieve AE Title included in Storage Commitment " + "N-EVENT-REPORT outside of the Referenced SOP Sequence."); scRetrieveAET.addOption(OptionBuilder.create("scretraet")); opts.addOptionGroup(scRetrieveAET); opts.addOption("screusefrom", false, "attempt to issue the Storage Commitment N-EVENT-REPORT on " + "the same Association on which the N-ACTION operation was " + "performed; use different Association for N-EVENT-REPORT by " + "default."); opts.addOption("screuseto", false, "attempt to issue the Storage Commitment N-EVENT-REPORT on " + "previous initiated Association to the Storage Commitment SCU; " + "initiate new Association for N-EVENT-REPORT by default."); OptionBuilder.withArgName("port"); OptionBuilder.hasArg(); OptionBuilder.withDescription("port of Storage Commitment SCU to connect to issue " + "N-EVENT-REPORT on different Association; 104 by default."); opts.addOption(OptionBuilder.create("scport")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder .withDescription("delay in ms for N-EVENT-REPORT-RQ to Storage Commitment SCU, " + "1s by default"); opts.addOption(OptionBuilder.create("scdelay")); OptionBuilder.withArgName("retry"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "number of retries to issue N-EVENT-REPORT-RQ to Storage " + "Commitment SCU, 0 by default"); opts.addOption(OptionBuilder.create("scretry")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("interval im ms between retries to issue N-EVENT-REPORT-RQ to" + "Storage Commitment SCU, 60s by default"); opts.addOption(OptionBuilder.create("scretryperiod")); OptionBuilder.withArgName("maxops"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "maximum number of outstanding operations performed " + "asynchronously, unlimited by default."); opts.addOption(OptionBuilder.create("async")); opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, " + "pack command and data PDV in one P-DATA-TF PDU by default."); opts.addOption("tcpdelay", false, "set TCP_NODELAY socket option to false, true by default"); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for TCP connect, no timeout by default"); opts.addOption(OptionBuilder.create("connectTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("rspTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-ASSOCIATE-AC, 5s by default"); opts.addOption(OptionBuilder.create("acceptTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for Socket close after sending A-ABORT, 50ms by default"); opts.addOption(OptionBuilder.create("soclosedelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("delay in ms for DIMSE-RSP; useful for testing asynchronous mode"); opts.addOption(OptionBuilder.create("rspdelay")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving -ASSOCIATE-RQ, 5s by default"); opts.addOption(OptionBuilder.create("requestTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving A-RELEASE-RP, 5s by default"); opts.addOption(OptionBuilder.create("releaseTO")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("period in ms to check for outstanding DIMSE-RSP, 10s by default"); opts.addOption(OptionBuilder.create("reaper")); OptionBuilder.withArgName("ms"); OptionBuilder.hasArg(); OptionBuilder.withDescription("timeout in ms for receiving DIMSE-RQ, 60s by default"); opts.addOption(OptionBuilder.create("idleTO")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of received P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("rcvpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("maximal length in KB of sent P-DATA-TF PDUs, 16KB by default"); opts.addOption(OptionBuilder.create("sndpdulen")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_RCVBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sorcvbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("set SO_SNDBUF socket option to specified value in KB"); opts.addOption(OptionBuilder.create("sosndbuf")); OptionBuilder.withArgName("KB"); OptionBuilder.hasArg(); OptionBuilder.withDescription("minimal buffer size to write received object to file, 1KB by default"); opts.addOption(OptionBuilder.create("bufsize")); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("dcmrcv: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption("V")) { Package p = DcmRcv.class.getPackage(); System.out.println("dcmrcv v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption("h") || cl.getArgList().size() == 0) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:com.archivas.clienttools.arcmover.cli.ArcDelete.java
protected void parseArgs() throws ParseException { // create the command cmdLine parser CommandLineParser parser = new PosixParser(); CommandLine cmdLine; // parse the command cmdLine arguments cmdLine = parser.parse(getOptions(), getArgs()); // Help// w w w .j a va 2 s . c om printHelp = cmdLine.hasOption("h"); if (printHelp) { return; } initializeProfiles(cmdLine.hasOption("insecure")); @SuppressWarnings({ "unchecked" }) List<String> argList = cmdLine.getArgList(); // Handle the load schedule and export lists LoadSchedule schedule = LoadSchedule.getDefaultLoadSchedule(); getLoadSchedule(cmdLine, schedule); setUpExportListThread(cmdLine); // Check for debug setting where we can rerun a job -- this is for testing purposes only // Validate the input file if one was provided // See if we are rerunning, set up the job if we are boolean rerunning = handleRerunAndResume(cmdLine, schedule); if (rerunning) { List<String> extraOptions = new ArrayList<String>(); if (cmdLine.hasOption(PROFILE_OPTION)) { extraOptions.add(PROFILE_OPTION); } if (cmdLine.hasOption(PATH_OPTION)) { extraOptions.add(PATH_OPTION); } if (cmdLine.hasOption(OPERATION_OPTION)) { extraOptions.add(OPERATION_OPTION); } if (cmdLine.hasOption(REASON_OPTION)) { extraOptions.add(REASON_OPTION); } if (cmdLine.hasOption(JOB_NAME)) { extraOptions.add(JOB_NAME); } if (!extraOptions.isEmpty()) { throw new ParseException("The following supplied options are not allowed with --" + RESUME + " or --" + RERUN + ": " + extraOptions); } // The list_file is not allowed for rerun/resume if (argList.size() > numCmdLineArgs - 1) { throw new ParseException( "The list_file argument is not allowed with --" + RESUME + " or --" + RERUN); } } else { if (argList.size() != numCmdLineArgs) { throw new ParseException("Missing argument list_file."); } // Get the name of the input file String listFileName = argList.get(numCmdLineArgs - 1); // Required fields String srcProfileName = getProfileNameFromCmdLineAndValidateExistance(cmdLine, PROFILE_OPTION); AbstractProfileBase srcProfile = ProfileManager.getProfileByName(srcProfileName); // Optional fields String sourcePath = null; if (cmdLine.hasOption(PATH_OPTION)) { sourcePath = cmdLine.getOptionValue(PATH_OPTION); srcProfile.setDisplayPath(sourcePath); } String jobName = null; if (cmdLine.hasOption(JOB_NAME)) { jobName = cmdLine.getOptionValue(JOB_NAME); } DeleteJob.Operation operation = DeleteJob.Operation.DELETE; String reason = null; if (srcProfile instanceof Hcp3AuthNamespaceProfile) { if (cmdLine.hasOption(OPERATION_OPTION)) { String operationStr = cmdLine.getOptionValue(OPERATION_OPTION); try { operation = DeleteJob.Operation.getFromString(operationStr); } catch (IllegalArgumentException e) { throw new ParseException(e.getMessage()); } } // Make sure if the operation if a privileged on that we get a reason if (operation.isPrivilegedOperation()) { if (!cmdLine.hasOption(REASON_OPTION)) { throw new ParseException("The " + REASON_OPTION + " option is required with a " + operation.getStringRepresentation() + " operation."); } reason = cmdLine.getOptionValue(REASON_OPTION); } else { if (cmdLine.hasOption(REASON_OPTION)) { throw new ParseException("The " + REASON_OPTION + " option is only supported for " + DeleteJob.Operation.PRIVILEGED_DELETE.getStringRepresentation() + " and " + DeleteJob.Operation.PRIVILEGED_PURGE.getStringRepresentation() + " operations."); } } } else { List<String> extraOptions = new ArrayList<String>(); if (cmdLine.hasOption(OPERATION_OPTION)) { extraOptions.add(OPERATION_OPTION); } if (cmdLine.hasOption(REASON_OPTION)) { extraOptions.add(REASON_OPTION); } if (!extraOptions.isEmpty()) { throw new ParseException( "The following supplied options are only supported for HCP namespaces: " + extraOptions); } } // Validate the input file try { FileListParser.validateFile(new File(listFileName), srcProfile, sourcePath, ""); } catch (IOException e) { throw new ParseException("Error parsing input file. Msg: " + e.getMessage()); } catch (FileListParserException e) { throw new ParseException("Error parsing input file. Msg: " + e.getMessage()); } // Setup the job with the arguments try { setupDeleteJob(listFileName, srcProfile, sourcePath, jobName, operation, reason, schedule); managedJobImpl = arcMover.createManagedJob(managedJob); } catch (IllegalArgumentException e) { throw new ParseException( "IllegalArgumentException writing to database during file list parsing. Msg: " + e.getMessage()); } catch (DatabaseException e) { throw new ParseException( "DatabaseException writing to database during file list parsing. Msg: " + e.getMessage()); } catch (JobException e) { throw new ParseException( "JobException writing to database during file list parsing. Msg: " + e.getMessage()); } } }
From source file:com.netflix.exhibitor.standalone.ExhibitorCreator.java
public ExhibitorCreator(String[] args) throws Exception { ExhibitorCLI cli = new ExhibitorCLI(); CommandLine commandLine; try {// ww w . j a va 2 s .c o m CommandLineParser parser = new PosixParser(); commandLine = parser.parse(cli.getOptions(), args); if (commandLine.hasOption('?') || commandLine.hasOption(HELP) || (commandLine.getArgList().size() > 0)) { throw new ExhibitorCreatorExit(cli); } } catch (UnrecognizedOptionException e) { throw new ExhibitorCreatorExit("Unknown option: " + e.getOption(), cli); } catch (ParseException e) { throw new ExhibitorCreatorExit(cli); } checkMutuallyExclusive(cli, commandLine, S3_BACKUP, FILESYSTEMBACKUP); String s3Region = commandLine.getOptionValue(S3_REGION, null); PropertyBasedS3Credential awsCredentials = null; if (commandLine.hasOption(S3_CREDENTIALS)) { awsCredentials = new PropertyBasedS3Credential(new File(commandLine.getOptionValue(S3_CREDENTIALS))); } BackupProvider backupProvider = null; if ("true".equalsIgnoreCase(commandLine.getOptionValue(S3_BACKUP))) { backupProvider = new S3BackupProvider(new S3ClientFactoryImpl(), awsCredentials, s3Region); } else if ("true".equalsIgnoreCase(commandLine.getOptionValue(FILESYSTEMBACKUP))) { backupProvider = new FileSystemBackupProvider(); } int timeoutMs = Integer.parseInt(commandLine.getOptionValue(TIMEOUT, "30000")); int logWindowSizeLines = Integer.parseInt(commandLine.getOptionValue(LOGLINES, "1000")); int configCheckMs = Integer.parseInt(commandLine.getOptionValue(CONFIGCHECKMS, "30000")); String useHostname = commandLine.getOptionValue(HOSTNAME, cli.getHostname()); int httpPort = Integer.parseInt(commandLine.getOptionValue(HTTP_PORT, "8080")); String extraHeadingText = commandLine.getOptionValue(EXTRA_HEADING_TEXT, null); boolean allowNodeMutations = "true".equalsIgnoreCase(commandLine.getOptionValue(NODE_MUTATIONS, "true")); String configType = commandLine.hasOption(SHORT_CONFIG_TYPE) ? commandLine.getOptionValue(SHORT_CONFIG_TYPE) : (commandLine.hasOption(CONFIG_TYPE) ? commandLine.getOptionValue(CONFIG_TYPE) : null); if (configType == null) { throw new MissingConfigurationTypeException( "Configuration type (-" + SHORT_CONFIG_TYPE + " or --" + CONFIG_TYPE + ") must be specified", cli); } ConfigProvider configProvider = makeConfigProvider(configType, cli, commandLine, awsCredentials, backupProvider, useHostname, s3Region); if (configProvider == null) { throw new ExhibitorCreatorExit(cli); } boolean isNoneConfigProvider = (configProvider instanceof NoneConfigProvider); if (isNoneConfigProvider) { backupProvider = null; } JQueryStyle jQueryStyle; try { jQueryStyle = JQueryStyle.valueOf(commandLine.getOptionValue(JQUERY_STYLE, "red").toUpperCase()); } catch (IllegalArgumentException e) { throw new ExhibitorCreatorExit(cli); } securityFile = commandLine.getOptionValue(SECURITY_FILE); realmSpec = commandLine.getOptionValue(REALM); remoteAuthSpec = commandLine.getOptionValue(REMOTE_CLIENT_AUTHORIZATION); String realm = commandLine.getOptionValue(BASIC_AUTH_REALM); String user = commandLine.getOptionValue(CONSOLE_USER); String password = commandLine.getOptionValue(CONSOLE_PASSWORD); String curatorUser = commandLine.getOptionValue(CURATOR_USER); String curatorPassword = commandLine.getOptionValue(CURATOR_PASSWORD); SecurityHandler handler = null; if (notNullOrEmpty(realm) && notNullOrEmpty(user) && notNullOrEmpty(password) && notNullOrEmpty(curatorUser) && notNullOrEmpty(curatorPassword)) { log.warn(Joiner.on(", ").join(BASIC_AUTH_REALM, CONSOLE_USER, CONSOLE_PASSWORD, CURATOR_USER, CURATOR_PASSWORD) + " - have been deprecated. Use TBD instead"); handler = makeSecurityHandler(realm, user, password, curatorUser, curatorPassword); } String aclId = commandLine.getOptionValue(ACL_ID); String aclScheme = commandLine.getOptionValue(ACL_SCHEME); String aclPerms = commandLine.getOptionValue(ACL_PERMISSIONS); ACLProvider aclProvider = null; if (notNullOrEmpty(aclId) || notNullOrEmpty(aclScheme) || notNullOrEmpty(aclPerms)) { aclProvider = getAclProvider(cli, aclId, aclScheme, aclPerms); if (aclProvider == null) { throw new ExhibitorCreatorExit(cli); } } ServoRegistration servoRegistration = null; if ("true".equalsIgnoreCase(commandLine.getOptionValue(SERVO_INTEGRATION, "false"))) { servoRegistration = new ServoRegistration(new JmxMonitorRegistry("exhibitor"), 60000); } String preferencesPath = commandLine.getOptionValue(PREFERENCES_PATH); this.builder = ExhibitorArguments.builder().connectionTimeOutMs(timeoutMs) .logWindowSizeLines(logWindowSizeLines).thisJVMHostname(useHostname).configCheckMs(configCheckMs) .extraHeadingText(extraHeadingText).allowNodeMutations(allowNodeMutations).jQueryStyle(jQueryStyle) .restPort(httpPort).aclProvider(aclProvider).servoRegistration(servoRegistration) .preferencesPath(preferencesPath); this.securityHandler = handler; this.backupProvider = backupProvider; this.configProvider = configProvider; this.httpPort = httpPort; }
From source file:com.archivas.clienttools.arcmover.cli.ArcProfileMgr.java
@SuppressWarnings({ "UnusedCatchParameter" }) protected void parseArgs() throws ParseException { // create the command cmdLine parser CommandLineParser parser = new PosixParser(); CommandLine cmdLine; // parse the command cmdLine arguments cmdLine = parser.parse(getOptions(), getArgs()); List<String> argList = cmdLine.getArgList(); printHelp = cmdLine.hasOption("h"); if (printHelp) { return;// ww w . j a va2s . co m } listProfiles = cmdLine.hasOption("l"); printProfile = cmdLine.hasOption("p"); createProfile = cmdLine.hasOption("c"); deleteProfile = cmdLine.hasOption("d"); // Make sure only one of these is set if ((listProfiles && printProfile) || (listProfiles && createProfile) || (listProfiles && createProfile) || (printProfile && createProfile) || (printProfile && deleteProfile) || (createProfile && deleteProfile)) { throw new ParseException(" You may not specify more than one '-lpcd' option"); } // Do validation if (printProfile) { profileName = getProfileNameFromCmdLineAndValidateExistance(cmdLine, "p"); } if (createProfile) { profileName = getProfileNameAndValidateItDoesNotExist(cmdLine, "c"); newProfileType = validateProfileType(cmdLine); dontTest = cmdLine.hasOption("notest"); authAnon = cmdLine.hasOption("anon"); validateCustomMetadata = cmdLine.hasOption("check-cm"); newProfileIPList = validateIPs(cmdLine); newProfileUseIPs = newProfileIPList != null && newProfileIPList.size() > 0; if (newProfileType.equals(HCAPProfile.HCAP_TYPE) || newProfileType.equals(Hcp3DefaultNamespaceProfile.HCAP_TYPE)) { // Default Namespace if (!newProfileUseIPs) { // Only use hostname when not using IPs newProfileHostname = validateHostname(cmdLine); } newProfileRequireSSL = validateRequireSSL(cmdLine); if (authAnon) { throw new ParseException("Anonymous access only allowed with HCP 5.0 or later profile type."); } } else if (newProfileType.equals(Hcp3AuthNamespaceProfile.HCAP_TYPE) || newProfileType.equals(Hcp5AuthNamespaceProfile.HCAP_TYPE) || newProfileType.equals(Hcp6AuthNamespaceProfile.HCAP_TYPE)) { // Authenticated Namespace newProfileHostname = validateHostname(cmdLine); newProfileRequireSSL = validateRequireSSL(cmdLine); newProfileTenant = validateTenant(cmdLine); newProfileNamespace = validateNamespace(cmdLine); if (authAnon) { if (cmdLine.hasOption("username") || cmdLine.hasOption("password")) { throw new ParseException("Cannot specify ANON and a username or password!"); } } else { newProfileUsername = validateUsername(cmdLine); newProfilePassword = validatePassword(cmdLine); } } if (ALLOW_PORT) { newProfilePort = validatePort(cmdLine); } } if (deleteProfile) { profileName = getProfileNameFromCmdLineAndValidateExistance(cmdLine, "d"); if (profileName.equalsIgnoreCase(LFS) || profileName.equalsIgnoreCase(FileSystemProfile.DEFAULT_FILESYSTEM_PROFILE_NAME)) { throw new ParseException("Cannot delete the default file system profile."); } } if (listProfiles) { // If there is a profile name we are just printing info about that profile if (argList.size() > 1) { throw new ParseException("-l takes 0 or 1 arguments"); } else if (argList.size() == 1) { String namePassedIn = cmdLine.getOptionValue('l'); if (namePassedIn != null) { listProfiles = false; printProfile = true; profileName = validateProfileNameExists(namePassedIn); } } } }
From source file:de.pixida.logtest.buildserver.RunIntegrationTests.java
private Map<File, List<Pair<File, Map<String, String>>>> groupAutomatonsByTraceFile(final CommandLine params) throws ParseException { final File logFolder = new File(commandLineParamOrCurrentDirectory(params, TRACE_LOG_DIRECTORY_SWITCH)); final File automatonsFolder = new File( commandLineParamOrCurrentDirectory(params, AUTOMATON_DIRECTORY_SWITCH)); LOG.debug("Using log folder: {}", logFolder.getAbsolutePath()); LOG.debug("Using automatons folder: {}", automatonsFolder.getAbsolutePath()); final Map<File, List<Pair<File, Map<String, String>>>> result = new HashMap<>(); for (final String arg : params.getArgList()) { final int numComponentsLogFileAndAutomaton = 2; final int numComponentsLogFileAndAutomatonAndParameter = 3; final String[] components = arg.split(":", numComponentsLogFileAndAutomatonAndParameter); if (components.length < numComponentsLogFileAndAutomaton || components.length > numComponentsLogFileAndAutomatonAndParameter) { throw new ParseException( "Invalid execution entry on command line. Format must be <logfile>:<automaton>[:<parameters>]: " + arg);//from www.jav a 2 s .co m } final File traceLog = new File(logFolder, components[0]); List<Pair<File, Map<String, String>>> automatons = result.get(traceLog); if (automatons == null) { automatons = new ArrayList<>(); result.put(traceLog, automatons); } Map<String, String> parameters = null; if (components.length >= numComponentsLogFileAndAutomatonAndParameter) { parameters = this .parseAutomatonParameters(components[numComponentsLogFileAndAutomatonAndParameter - 1]); } if (parameters == null) { parameters = this.parseAutomatonParameters(""); } automatons.add(Pair.of(new File(automatonsFolder, components[1]), parameters)); } return result; }
From source file:com.alibaba.wasp.master.FMasterCommandLine.java
public int run(String args[]) throws Exception { Options opt = new Options(); opt.addOption("minServers", true, "Minimum FServers needed to host user tables"); opt.addOption("backup", false, "Do not try to become FMaster until the primary fails"); CommandLine cmd; try {// w w w . j ava 2 s . c o m cmd = new GnuParser().parse(opt, args); } catch (ParseException e) { LOG.error("Could not parse: ", e); usage(null); return -1; } if (cmd.hasOption("minServers")) { String val = cmd.getOptionValue("minServers"); getConf().setInt("wasp.fserver.count.min", Integer.valueOf(val)); LOG.debug("minServers set to " + val); } // check if we are the backup master - override the conf if so if (cmd.hasOption("backup")) { getConf().setBoolean(FConstants.MASTER_TYPE_BACKUP, true); } List<String> remainingArgs = cmd.getArgList(); if (remainingArgs.size() != 1) { usage(null); return -1; } String command = remainingArgs.get(0); if ("start".equals(command)) { return startMaster(); } else if ("stop".equals(command)) { return stopMaster(); } else if ("clear".equals(command)) { return (ZNodeClearer.clear(getConf()) ? 0 : -1); } else { usage("Invalid command: " + command); return -1; } }
From source file:edu.umn.msi.gx.mztosqlite.MzToSQLite.java
public final void parseOptions(String[] args) { Integer MAX_INPUTS = 100;/*from w w w . j a va2s .co m*/ Parser parser = new BasicParser(); String dbOpt = "sqlite"; String inputFileOpt = "input"; String inputNameOpt = "name"; String inputIdOpt = "encoded_id"; String verboseOpt = "verbose"; String helpOpt = "help"; Options options = new Options(); options.addOption("s", dbOpt, true, "SQLite output file"); options.addOption("v", verboseOpt, false, "verbose"); options.addOption("h", helpOpt, false, "help"); options.addOption("i", inputFileOpt, verbose, "input file"); options.addOption("n", inputNameOpt, verbose, "name for input file"); options.addOption("e", inputIdOpt, verbose, "encoded id for input file"); options.addOption("f", inputIdOpt, verbose, "FASTA Search Database files"); options.getOption(inputFileOpt).setArgs(MAX_INPUTS); options.getOption(inputNameOpt).setArgs(MAX_INPUTS); options.getOption(inputIdOpt).setArgs(MAX_INPUTS); // create the parser try { // parse the command line arguments CommandLine cli = parser.parse(options, args); if (cli.hasOption(helpOpt)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar MzToSQLite.jar [options] [proteomics_data_file ...]", options); exit(0); } if (cli.hasOption(verboseOpt)) { verbose = true; } if (cli.hasOption(dbOpt)) { dbPath = cli.getOptionValue(dbOpt); mzSQLiteDB = new MzSQLiteDB(dbPath); try { mzSQLiteDB.createTables(); } catch (SqlJetException ex) { Logger.getLogger(MzToSQLite.class.getName()).log(Level.SEVERE, null, ex); } } List<String> argList = cli.getArgList(); if (argList != null) { for (String filePath : argList) { File inputFile = new File(filePath); if (inputFile.canRead()) { try { ProteomicsFormat format = ProteomicsFormat.getFormat(inputFile); switch (format) { case MZID: identFiles.put(filePath, format); break; case MZML: case MGF: case DTA: case MS2: case PKL: case MZXML: case XML_FILE: case MZDATA: case PRIDEXML: scanFiles.put(filePath, format); break; case FASTA: seqDbFiles.put(filePath, format); break; case PEPXML: case UNSUPPORTED: default: Logger.getLogger(MzToSQLite.class.getName()).log(Level.WARNING, "Unknown or unsupported format: {0}", filePath); break; } } catch (IOException ex) { Logger.getLogger(MzToSQLite.class.getName()).log(Level.SEVERE, null, ex); } } else { Logger.getLogger(MzToSQLite.class.getName()).log(Level.WARNING, "Unable to read {0}", filePath); } } } } catch (ParseException exp) { Logger.getLogger(MzToSQLite.class.getName()).log(Level.SEVERE, null, exp); } }
From source file:mod.org.dcm4che2.tool.DcmSnd.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();//from w ww .ja v a 2 s. 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; }
From source file:com.upload.DcmSnd.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("name"); OptionBuilder.hasArg();/*ww w.j a v a 2 s . 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; }