Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineException


        AbstractProject s = h.getItemByFullName(src,AbstractProject.class);
        if (s==null) {
            AbstractProject nearest = AbstractProject.findNearest(src);
            if (nearest!=null)
                throw new CmdLineException(owner, "No such job '"+src+"' perhaps you meant '"+ nearest.getFullName() +"'?");
            else
                throw new CmdLineException(owner, "No such job '"+src+"'");
        }
        setter.addValue(s);
        return 1;
    }
View Full Code Here


    @Override
    protected int run() throws Exception {
        Authentication a = Jenkins.getAuthentication();
        if (a== Jenkins.ANONYMOUS)
            throw new CmdLineException("No credentials specified."); // this causes CLI to show the command line options.

        ClientAuthenticationCache store = new ClientAuthenticationCache(checkChannel());
        store.set(a);

        return 0;
View Full Code Here

      parser.parseArgument(args.toArray(new String[] {}));

      compilationLevelParsed =
          COMPILATION_LEVEL_MAP.get(compilationLevel.toUpperCase());
      if (compilationLevelParsed == null) {
        throw new CmdLineException(
            parser, "Bad value for --compilation_level: " + compilationLevel);
      }

    }
View Full Code Here

          matchPaths(pattern, allJsInputs);
        }
      }

      if (!patterns.isEmpty() && allJsInputs.isEmpty()) {
        throw new CmdLineException(new CmdLineParser(this), "No inputs matched");
      }

      return new ArrayList<>(allJsInputs);
    }
View Full Code Here

      Splitter splitter = Splitter.on('|').limit(2);
      for (String locationMapping : sourceMapLocationMapping) {
        List<String> parts = splitter.splitToList(locationMapping);
        if (parts.size() != 2) {
          throw new CmdLineException(
            "Bad value for --source_map_location_mapping: " +
            ImmutableList.of(sourceMapLocationMapping));
        }
        locationMappings.add(new SourceMap.LocationMapping(parts.get(0), parts.get(1)));
      }
View Full Code Here

    @CLIResolver
    public static AbstractProject resolveForCLI(
            @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
        AbstractProject item = Jenkins.getInstance().getItemByFullName(name, AbstractProject.class);
        if (item==null)
            throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
        return item;
    }
View Full Code Here

        TimeSpan value;
        try {
            value = TimeSpan.parse(s);
        } catch (Exception e) {
            if (option.isArgument()) {
                throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND.format(option.toString(), s));
            } else {
                throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND.format(params.getParameter(-1), s));
            }
        }

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

        || "off".equals(value)
        || "0".equals(value)) {
      return false;
    }

    throw new CmdLineException(parser, String.format(
        "invalid boolean \"%s=%s\"", name, value));
  }
View Full Code Here

          case CLIENT_SSL_CERT_LDAP:
          case LDAP:
            accountId = createAccountByLdap(token);
            break;
          default:
            throw new CmdLineException(owner, "user \"" + token + "\" not found");
        }
      }
    } catch (OrmException e) {
      throw new CmdLineException(owner, "database is down");
    }
    setter.addValue(accountId);
    return 1;
  }
View Full Code Here

  }

  private Account.Id createAccountByLdap(String user)
      throws CmdLineException {
    if (!user.matches(Account.USER_NAME_PATTERN)) {
      throw new CmdLineException(owner, "user \"" + user + "\" not found");
    }

    try {
      AuthRequest req = AuthRequest.forUser(user);
      req.setSkipAuthentication(true);
      return accountManager.authenticate(req).getAccountId();
    } catch (AccountException e) {
      throw new CmdLineException(owner, "user \"" + user + "\" not found");
    }
  }
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.