Package org.apache.commons.cli

Examples of org.apache.commons.cli.ParseException


    try {
      return Integer.parseInt(portString);
    }
    catch (NumberFormatException e) {
      throw new ParseException("Invalid port number '" + portString + "'");
    }
  }
View Full Code Here


    try {
      return Integer.parseInt(sslPortString);
    }
    catch (NumberFormatException e) {
      throw new ParseException("Invalid port number '" + sslPortString + "'");
    }
  }
View Full Code Here

    try {
      return Integer.parseInt(ageString);
    }
    catch (NumberFormatException e) {
      throw new ParseException("Invalid maxCacheAge value '" + ageString + "'");
    }
  }
View Full Code Here

        if (sp != null)
            main.splitPattern = sp;

        if (main.isScriptFile) {
            if (args.isEmpty())
                throw new ParseException("neither -e or filename provided");

            main.script = (String) args.remove(0);
            if (main.script.endsWith(".java"))
                throw new ParseException("error: cannot compile file with .java extension: " + main.script);
        } else {
            main.script = line.getOptionValue('e');
        }

        main.processSockets = line.hasOption('l');
View Full Code Here

      return false;
    }

    if (commandLine.hasOption("filename") && commandLine.hasOption("dirname")) {
      throw new ParseException(
          "--filename and --dirname options cannot be used simultaneously");
    }

    if (!commandLine.hasOption("port")) {
      throw new ParseException(
          "You must specify a port to connect to with --port");
    }

    port = Integer.parseInt(commandLine.getOptionValue("port"));

    if (!commandLine.hasOption("host")) {
      throw new ParseException(
          "You must specify a hostname to connect to with --host");
    }

    hostname = commandLine.getOptionValue("host");
    fileName = commandLine.getOptionValue("filename");
View Full Code Here

              path = configurationFile.getCanonicalPath();
            } catch (IOException ex) {
              logger.error("Failed to read canonical path for file: " + path,
                ex);
            }
            throw new ParseException(
              "The specified configuration file does not exist: " + path);
          }
        }
        List<LifecycleAware> components = Lists.newArrayList();
View Full Code Here

        try {
            CommandLine line = new PosixParser().parse(options, args);
            if (line.hasOption(TRAIN_TAXONFILE_SHORT_OPT) ) {
              tax_file = line.getOptionValue(TRAIN_TAXONFILE_SHORT_OPT);
            } else {
                throw new ParseException("Taxonomy file must be specified");
            }
            if (line.hasOption(TRAIN_SEQFILE_SHORT_OPT) ) {
              source_file = line.getOptionValue(TRAIN_SEQFILE_SHORT_OPT);
            } else {
                throw new ParseException("Source training fasta file must be specified");
            }
            if (line.hasOption(OUTFILE_SHORT_OPT) ) {
              out_file = line.getOptionValue(OUTFILE_SHORT_OPT);
            } else {
                throw new ParseException("Output file must be specified");
            }

            if (line.hasOption(LENGTH_SHORT_OPT) ) {
;              partialLength = new Integer(line.getOptionValue(LENGTH_SHORT_OPT));
            }
View Full Code Here

    CommandLineParser parser = new GnuParser();
    CommandLine line;
    try {
      line = parser.parse( options, args );
      if (line.getArgs().length != 0) {
        throw new ParseException("Unexpected options");
      }
    } catch (ParseException pe) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("TestFileAppend2", options);
      throw pe;
View Full Code Here

      }
     
      boolean hasGetEdit = cmdLine.hasOption(geteditsizeOpt.getOpt());
      boolean hasCheckpoint = cmdLine.hasOption(checkpointOpt.getOpt());
      if (hasGetEdit && hasCheckpoint) {
        throw new ParseException("May not pass both "
            + geteditsizeOpt.getOpt() + " and "
            + checkpointOpt.getOpt());
      }
     
      if (hasGetEdit) {
        cmd = Command.GETEDITSIZE;
      } else if (hasCheckpoint) {
        cmd = Command.CHECKPOINT;
       
        String arg = cmdLine.getOptionValue(checkpointOpt.getOpt());
        if ("force".equals(arg)) {
          shouldForce = true;
        } else if (arg != null) {
          throw new ParseException("-checkpoint may only take 'force' as an "
              + "argument");
        }
      }
     
      if (cmdLine.hasOption(formatOpt.getOpt())) {
View Full Code Here

            {
                this.port = Integer.parseInt(portNum);
            }
            catch (NumberFormatException e)
            {
                throw new ParseException("Port must be a number");
            }
        }
        else
        {
            this.port = defaultPort;
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.ParseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.