Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineException


    protected Path parse(String argument) throws NumberFormatException, CmdLineException {
        try {
        return Paths.get(argument);
        }
        catch (Exception e) {
            throw new CmdLineException(owner, "Failed to Parse Path: " + argument, e);
        }
    }
View Full Code Here


        CmdLineParser parser = new CmdLineParser(arguments);
        try {
            parser.parseArgument(args);
            arguments.cmdLineParser = parser;
            if (Strings2.isEmpty(arguments.pid) && arguments.pidFile == null) {
                throw new CmdLineException(parser, "Options --pid and --pid-file can NOT be both null");
            } else if (!Strings2.isEmpty(arguments.pid) && arguments.pidFile != null) {
                throw new CmdLineException(parser, "Options --pid and --pid-file can NOT be both defined");
            } else if (
                    (arguments.attribute == null || arguments.attribute.length == 0) &&
                            (arguments.operation == null || arguments.operation.length == 0) &&
                            arguments.listMbeans == false && arguments.describeMbeans == false) {
                throw new CmdLineException(parser, "Option --attribute or --operation or --list-mbeans or --describe-mbeans must be defined");
            } else if (
                    (arguments.attribute != null && arguments.attribute.length > 0) &&
                            (arguments.operation != null && arguments.operation.length > 0)) {
                throw new CmdLineException(parser, "Options --attribute and --operation can NOT be both defined");
            }


            String logLevel;
            if (arguments.superVerbose) {
View Full Code Here

                } else if (arguments.describeMbeans) {
                    result = describeMbean(mbeanServer, objectName);
                } else if (arguments.listMbeans) {
                    result = objectName;
                } else {
                    throw new CmdLineException(arguments.cmdLineParser, "NO SEARCH_MBEANS OR OPERATION  OR ATTRIBUTE DEFINED");
                }
            } catch (Exception e) {
                StringWriter sw = new StringWriter();
                e.printStackTrace(new PrintWriter(sw));
                result = "## EXCEPTION ##\n" + sw.toString();
View Full Code Here

    parser.setUsageWidth(80);

    try {
      parser.parseArgument(args);
      if (options.arguments.size() < 1) {
        throw new CmdLineException(parser,
            "missing argument: <logfile>");
      }
      if (options.arguments.size() < 2) {
        throw new CmdLineException(parser,
            "missing argument: <target-url>");
      }
    } catch (CmdLineException e) {
      System.err.println("error: " + e.getMessage());
      System.err
View Full Code Here

    String token = params.getParameter(0);
    try {
      int value = Integer.parseInt(token);
      setter.addValue(value);
    } catch (NumberFormatException e) {
      throw new CmdLineException(Messages.ILLEGAL_OPERAND.format(option.toString(), token));
    }
    return 1;
  }
View Full Code Here

        try {
            double value = Double.parseDouble(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(Messages.ILLEGAL_OPERAND.format(option.toString(),s));
        setter.addValue(value);
        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

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

        CmdLineParser parser = new CmdLineParser(arguments);
        try {
            parser.parseArgument(args);
            arguments.cmdLineParser = parser;
            if (Strings2.isEmpty(arguments.pid) && arguments.pidFile == null) {
                throw new CmdLineException(parser, "Options --pid and --pid-file can NOT be both null");
            } else if (!Strings2.isEmpty(arguments.pid) && arguments.pidFile != null) {
                throw new CmdLineException(parser, "Options --pid and --pid-file can NOT be both defined");
            } else if (
                    (arguments.attribute == null || arguments.attribute.length == 0) &&
                            (arguments.operation == null || arguments.operation.length == 0)) {
                throw new CmdLineException(parser, "Option --attribute or --operation must be defined");
            } else if (
                    (arguments.attribute != null && arguments.attribute.length > 0) &&
                            (arguments.operation != null && arguments.operation.length > 0)) {
                throw new CmdLineException(parser, "Options --attribute and --operation can NOT be both defined");
            }


            String logLevel;
            if (arguments.superVerbose) {
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.