Package org.apache.commons.cli2

Examples of org.apache.commons.cli2.OptionException


 
  public boolean parseArgs(String[] args) {
    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();
    Option helpOpt = DefaultOptionCreator.helpOption();
   
    Option inputFileOpt = obuilder.withLongName("inputFile").withRequired(true).withArgument(
        abuilder.withName("inputFile").withMinimum(1).withMaximum(1).create()).withDescription(
        "The input file").withShortName("i").create();
   
    Option countFileOpt = obuilder.withLongName("countFile").withRequired(true).withArgument(
        abuilder.withName("countFile").withMinimum(1).withMaximum(1).create()).withDescription(
        "The tag count file").withShortName("c").create();
   
    Option outputFileOpt = obuilder.withLongName("outputFile").withRequired(true).withArgument(
        abuilder.withName("outputFile").withMinimum(1).withMaximum(1).create()).withDescription(
        "The output file").withShortName("c").create();
   
    Option solrUrlOpt = obuilder.withLongName("solrUrl").withRequired(true).withArgument(
        abuilder.withName("solrUrl").withMinimum(1).withMaximum(1).create()).withDescription(
        "URL of the solr server").withShortName("s").create();
   
    Group group = gbuilder.withName("Options")
      .withOption(inputFileOpt)
View Full Code Here


 
  public boolean parseArgs(String[] args) {
    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();
    Option helpOpt = DefaultOptionCreator.helpOption();
   
    Option inputFileOpt = obuilder.withLongName("inputFile").withRequired(true).withArgument(
        abuilder.withName("inputFile").withMinimum(1).withMaximum(1).create()).withDescription(
        "The input file").withShortName("i").create();
    Option outputFileOpt = obuilder.withLongName("outputFile").withRequired(true).withArgument(
        abuilder.withName("outputFile").withMinimum(1).withMaximum(1).create()).withDescription(
        "The output file").withShortName("o").create();

    Option limitOpt = obuilder.withLongName("limit").withRequired(false).withArgument(
        abuilder.withName("limit").withMinimum(1).withMaximum(1).create()).withDescription(
        "Emit this many of the most frequent tags").withShortName("l").create();
   
    Option cutoffOpt = obuilder.withLongName("cutoff").withRequired(false).withArgument(
        abuilder.withName("cutoff").withMinimum(1).withMaximum(1).create()).withDescription(
        "Drop tags with a count less than this number").withShortName("c").create();
   
    Group group = gbuilder.withName("Options").withOption(inputFileOpt)
      .withOption(outputFileOpt).withOption(limitOpt)
View Full Code Here

      testOutputDirectory = new Path((String) cmdLine.getValue(testOutputDirOpt));
    
      charset = Charset.forName((String) cmdLine.getValue(charsetOpt));

      if (cmdLine.hasOption(testSplitSizeOpt) && cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option, not BOTH");
      } else if (!cmdLine.hasOption(testSplitSizeOpt) && !cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option");
      }

      if (cmdLine.hasOption(testSplitSizeOpt)) {
        setTestSplitSize(Integer.parseInt((String) cmdLine.getValue(testSplitSizeOpt)));
      }
View Full Code Here

        if (wString.equalsIgnoreCase("tf")) {
          processIdf = false;
        } else if (wString.equalsIgnoreCase("tfidf")) {
          processIdf = true;
        } else {
          throw new OptionException(weightOpt);
        }
      } else {
        processIdf = true;
      }
     
View Full Code Here

            if (wString.equalsIgnoreCase("tf")) {
              weight = new TF();
            } else if (wString.equalsIgnoreCase("tfidf")) {
              weight = new TFIDF();
            } else {
              throw new OptionException(weightOpt);
            }
          } else {
            weight = new TFIDF();
          }
          String field = cmdLine.getValue(fieldOpt).toString();
View Full Code Here

          if (dictionaryType.equals("text")) {
            dictionary = VectorHelper.loadTermDictionary(new File(cmdLine.getValue(dictOpt).toString()));
          } else if (dictionaryType.equals("sequencefile")) {
            dictionary = VectorHelper.loadTermDictionary(conf, fs, cmdLine.getValue(dictOpt).toString());
          } else {
            throw new OptionException(dictTypeOpt);
          }
        }
        boolean useJSON = cmdLine.hasOption(centroidJSonOpt);
       
        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
View Full Code Here

    public void process(final WriteableCommandLine commandLine, final ListIterator arguments)
        throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN, arg);
      }

      ArrayList properties = new ArrayList();
      String next = "";
      while (arguments.hasNext()) {
        next = (String) arguments.next();
        if (!next.startsWith("-")) {

          if (keyValue && (next.indexOf("=") == -1)) {
            throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN, "argument: '"
                + next + "' is not of the form x=y");
          }
          properties.add(next);
        } else {
          arguments.previous();
View Full Code Here

    public void process(final WriteableCommandLine commandLine,
                        final ListIterator arguments) throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this,
                                  ResourceConstants.UNEXPECTED_TOKEN, arg);
      }
     
      ArrayList properties = new ArrayList();
      String next = "";
View Full Code Here

      testOutputDirectory = new Path((String) cmdLine.getValue(testOutputDirOpt));
    
      charset = Charset.forName((String) cmdLine.getValue(charsetOpt));

      if (cmdLine.hasOption(testSplitSizeOpt) && cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option, not BOTH");
      } else if (!cmdLine.hasOption(testSplitSizeOpt) && !cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option");
      }

      if (cmdLine.hasOption(testSplitSizeOpt)) {
        setTestSplitSize(Integer.parseInt((String) cmdLine.getValue(testSplitSizeOpt)));
      }
View Full Code Here

    public void process(final WriteableCommandLine commandLine,
                        final ListIterator arguments) throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this,
                                  ResourceConstants.UNEXPECTED_TOKEN, arg);
      }
     
      ArrayList properties = new ArrayList();
      String next = "";
View Full Code Here

TOP

Related Classes of org.apache.commons.cli2.OptionException

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.