Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineException


  public final int parseArguments(final Parameters params)
      throws CmdLineException {
    final String n = params.getParameter(0);
    final AccountGroup group = groupCache.get(new AccountGroup.NameKey(n));
    if (group == null) {
      throw new CmdLineException(owner, "Group \"" + n + "\" does not exist");
    }
    setter.addValue(group.getId());
    return 1;
  }
View Full Code Here


    final String token = params.getParameter(0);
    final PatchSet.Id id;
    try {
      id = PatchSet.Id.parse(token);
    } catch (IllegalArgumentException e) {
      throw new CmdLineException(owner, "\"" + token
          + "\" is not a valid patch set");
    }

    setter.addValue(id);
    return 1;
View Full Code Here

  public final int parseArguments(final Parameters params)
      throws CmdLineException {
    final String n = params.getParameter(0);
    final GroupReference group = GroupBackends.findBestSuggestion(groupBackend, n);
    if (group == null) {
      throw new CmdLineException(owner, "Group \"" + n + "\" does not exist");
    }
    setter.addValue(group.getUUID());
    return 1;
  }
View Full Code Here

      throws CmdLineException {
    final String token = params.getParameter(0);
    try {
      setter.addValue(SocketUtil.parse(token, 0));
    } catch (IllegalArgumentException e) {
      throw new CmdLineException(owner, e.getMessage());
    }
    return 1;
  }
View Full Code Here

  public final int parseArguments(final Parameters params)
      throws CmdLineException {
    final String token = params.getParameter(0);
    final String[] tokens = token.split(",");
    if (tokens.length != 3) {
      throw new CmdLineException(owner, "change should be specified as "
                                 + "<project>,<branch>,<change-id>");
    }

    try {
      final Change.Key key = Change.Key.parse(tokens[2]);
      final Project.NameKey project = new Project.NameKey(tokens[0]);
      final Branch.NameKey branch =
          new Branch.NameKey(project, "refs/heads/" + tokens[1]);
      for (final Change change : db.changes().byBranchKey(branch, key)) {
        setter.addValue(change.getId());
        return 1;
      }
    } catch (IllegalArgumentException e) {
      throw new CmdLineException(owner, "Change-Id is not valid");
    } catch (OrmException e) {
      throw new CmdLineException(owner, "Database error: " + e.getMessage());
    }

    throw new CmdLineException(owner, "\"" + token + "\": change not found");
  }
View Full Code Here

    final ProjectControl control;
    try {
      Project.NameKey nameKey = new Project.NameKey(projectName);
      control = projectControlFactory.validateFor(nameKey, ProjectControl.OWNER | ProjectControl.VISIBLE);
    } catch (NoSuchProjectException e) {
      throw new CmdLineException(owner, "'" + token + "': not a Gerrit project");
    }

    setter.addValue(control);
    return 1;
  }
View Full Code Here

        String param = params.getParameter(0);
        try {
            setter.addValue(new URI(param));
            return 1;
        } catch (URISyntaxException e) {
            throw new CmdLineException(owner, 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(owner, Messages.ILLEGAL_OPERAND.format(param));
        }
    }
View Full Code Here

                value = o;
                break;
            }

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

        try {
            T value = parse(token);
            setter.addValue(value);
        }
        catch (NumberFormatException ex) {
            throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND.format(option.toString(),token));
        }
        return 1;
 
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.