Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineException


      sourcePathFiles = new ArrayList<File>(sourceDirs.length);
      for (String sourceDirPath : sourceDirs) {
        // be tolerant, accept also '/' as file separator
        File sourceDir = new File(sourceDirPath.replace('/', File.separatorChar));
        if (!sourceDir.exists()) {
          throw new CmdLineException(owner, "directory or file does not exist: " + sourceDir.getAbsolutePath());
        }
        sourcePathFiles.add(sourceDir);
      }
    }
    if(sourcePathFiles == null) {
View Full Code Here


    for(int i = 0; i<parameters.size(); i++) {
      String sourcePath = parameters.getParameter(i);
       // be tolerant, accept also '/' as file separator
        File sourceFile = new File(sourcePath.replace('/', File.separatorChar));
        if (!sourceFile.exists()) {
          throw new CmdLineException(owner, "Source file does not exist: " + sourceFile.getAbsolutePath());
        }
      sourceFiles.add(sourceFile);

    }
    setter.addValue(sourceFiles);
View Full Code Here

    if ("false".equals(value) || "f".equals(value) || "no".equals(value) || "n".equals(value)
        || "off".equals(value) || "0".equals(value)) {
      return false;
    }

    throw new CmdLineException(parser, String.format("invalid boolean \"%s=%s\"", name, value));
  }
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(params.getParameter(-1),param));
        }
    }
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(owner, 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(owner, Messages.ILLEGAL_OPERAND.format(
                    params.getParameter(-1),param));
        }
    }
View Full Code Here

                break;
            }

        if(value==null) {
            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

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

    }

    private Boolean getBoolean(String parameter) throws CmdLineException {
        String valueStr = parameter.toLowerCase();
        if (!ACCEPTABLE_VALUES.containsKey(valueStr)) {
            throw new CmdLineException(owner, Messages.ILLEGAL_BOOLEAN.format(valueStr));
        }
        return ACCEPTABLE_VALUES.get(valueStr);
    }
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(owner, Messages.ILLEGAL_BOOLEAN.format(valueStr));
        }
        setter.addValue(index < ACCEPTABLE_VALUES.size() / 2);
        return 1;
      } else {
        setter.addValue(true);
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.