Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineException


    }

    final int dot2 = name.indexOf("..");
    if (dot2 != -1) {
      if (!option.isMultiValued())
        throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn
          , option.metaVar(), name));

      final String left = name.substring(0, dot2);
      final String right = name.substring(dot2 + 2);
      addOne(left, false);
View Full Code Here


      throws CmdLineException {
    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().notACommit, name));

    final RevCommit c;
    try {
      c = clp.getRevWalk().parseCommit(id);
    } catch (MissingObjectException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name));
    } catch (IncorrectObjectTypeException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name));
    } catch (IOException e) {
      throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
    }

    if (interesting)
      c.remove(RevFlag.UNINTERESTING);
    else
View Full Code Here

  }

  @Override
  protected Character parse(String argument) throws NumberFormatException, CmdLineException {
        if (argument.length() != 1)
            throw new CmdLineException(owner, Messages.ILLEGAL_CHAR, argument);
        return argument.charAt(0);
  }
View Full Code Here

        return fallback(subCmd);
    }

    protected int fallback(String subCmd) throws CmdLineException {
        throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND, option.toString(), subCmd);
    }
View Full Code Here

            // parser.parseArgument("more","args");

            // after parsing arguments, you should check
            // if enough arguments are given.
            if( arguments.isEmpty() )
                throw new CmdLineException(parser,"No argument is given");

        } catch( CmdLineException e ) {
            // if there's a problem in the command line,
            // you'll get this exception. this will report
            // an error message.
View Full Code Here

  public int parseArguments(Parameters params) throws CmdLineException {
    MapSetter mapSetter = (MapSetter)setter;
    try {
      mapSetter.addValue(params.getParameter(0));
    } catch (RuntimeException e) {
      throw new CmdLineException(e.getMessage());
    }
        return 1;
  }
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

    public int parseArguments(Parameters params) throws CmdLineException {
      if (option.isArgument()) {
        String valueStr = params.getParameter(0).toLowerCase();
        int index = ACCEPTABLE_VALUES.indexOf(valueStr);
        if (index == -1) {
          throw new CmdLineException(Messages.ILLEGAL_BOOLEAN.format(valueStr));
        }
        setter.addValue(index < ACCEPTABLE_VALUES.size() / 2);
        return 1;
      } else {
        setter.addValue(true);
View Full Code Here

  }

  @Override
  protected Character parse(String argument) throws NumberFormatException, CmdLineException {
        if (argument.length() != 1)
            throw new CmdLineException(Messages.ILLEGAL_CHAR.format(argument));
        return argument.charAt(0);
  }
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.