Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineException


        String param = params.getParameter(0);
        try {
            setter.addValue(new URI(param));
            return 1;
        } catch (URISyntaxException e) {
            throw new CmdLineException(Messages.ILLEGAL_OPERAND.format(param));
        }
    }
View Full Code Here


        String param = params.getParameter(0);
        try {
            setter.addValue(new URL(param));
            return 1;
        } catch (MalformedURLException e) {
            throw new CmdLineException(Messages.ILLEGAL_OPERAND.format(param));
        }
    }
View Full Code Here

        try {
            T value = parse(token);
            setter.addValue(value);
        }
        catch (NumberFormatException ex) {
            throw new CmdLineException(Messages.ILLEGAL_OPERAND.format(option.toString(),token));
        }
        return 1;
 
View Full Code Here

                value = o;
                break;
            }

        if(value==null)
            throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND.format(params.getParameter(-1),s));
        setter.addValue(value);
        return 1;
    }
View Full Code Here

    Pattern p;
    try {
      p = Pattern.compile(s);
    }
    catch (PatternSyntaxException x) {
      throw new CmdLineException(owner, Messages.ILLEGAL_PATTERN.format(option.toString(), s));
    }
    setter.addValue(p);
    return 1;
  }
View Full Code Here

      if (value < min.getValue() || value > max.getValue()) {
        final String name = cmdOption.name();
        final String e =
            "\"" + token + "\" must be in range " + min.formatValue() + ".."
                + max.formatValue() + " for \"" + name + "\"";
        throw new CmdLineException(owner, e);
      }
      return value;
    }
View Full Code Here

    final String name = params.getParameter(0);
    final ObjectId id;
    try {
      id = clp.getRepository().resolve(name);
    } catch (IOException e) {
      throw new CmdLineException(e.getMessage());
    }
    if (id != null) {
      setter.addValue(id);
      return 1;
    }

    throw new CmdLineException(MessageFormat.format(CLIText.get().notAnObject, name));
  }
View Full Code Here

  @Override
  public int parseArguments(final Parameters params) throws CmdLineException {
    final String name = params.getParameter(0);
    final CommandRef cr = CommandCatalog.get(name);
    if (cr == null)
      throw new CmdLineException(MessageFormat.format(
          CLIText.get().notAJgitCommand, name));

    // Force option parsing to stop. Everything after us should
    // be arguments known only to this command and must not be
    // recognized by the current parser.
View Full Code Here

    final String name = params.getParameter(0);
    final ObjectId id;
    try {
      id = clp.getRepository().resolve(name);
    } catch (IOException e) {
      throw new CmdLineException(e.getMessage());
    }
    if (id == null)
      throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));

    final RevTree c;
    try {
      c = clp.getRevWalk().parseTree(id);
    } catch (MissingObjectException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
    } catch (IncorrectObjectTypeException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
    } catch (IOException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
    }
    setter.addValue(c);
    return 1;
  }
View Full Code Here

    if (new File(name).isFile()) {
      final DirCache dirc;
      try {
        dirc = DirCache.read(new File(name), FS.DETECTED);
      } catch (IOException e) {
        throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e);
      }
      setter.addValue(new DirCacheIterator(dirc));
      return 1;
    }

    final ObjectId id;
    try {
      id = clp.getRepository().resolve(name);
    } catch (IOException e) {
      throw new CmdLineException(e.getMessage());
    }
    if (id == null)
      throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));

    final CanonicalTreeParser p = new CanonicalTreeParser();
    final ObjectReader curs = clp.getRepository().newObjectReader();
    try {
      p.reset(curs, clp.getRevWalk().parseTree(id));
    } catch (MissingObjectException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
    } catch (IncorrectObjectTypeException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
    } catch (IOException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
    } finally {
      curs.release();
    }

    setter.addValue(p);
View Full Code Here

TOP

Related Classes of org.kohsuke.args4j.CmdLineException

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.