Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineParser.parseArgument()


                "org.restlet.ext.slf4j.Slf4jLoggerFacade");
       
        CmdLineSettings settings = new CmdLineSettings();
        CmdLineParser parser = new CmdLineParser(settings);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            parser.printUsage(System.out);
            System.exit(1);
        }
       
View Full Code Here


        logger.info(">> updater running:");
        options = new CmdOptions();
        CmdLineParser parser = new CmdLineParser(options);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            logger.log(Level.SEVERE, null, e);
            System.err.println(e.getMessage());
            printUsage(parser);
            return;
View Full Code Here

    FlagsImpl flags = new FlagsImpl();
    CmdLineParser.registerHandler(List.class, StringListOptionHandler.class);
    CmdLineParser.registerHandler(Long.class, LongOptionHandler.class);
    CmdLineParser cmdLineParser = new CmdLineParser(flags);
    try {
      cmdLineParser.parseArgument(strings);
    } catch (CmdLineException e) {
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      cmdLineParser.printUsage(stream);
      throw new InvalidFlagException(e.getMessage(), stream.toString());
    }
View Full Code Here

      argString.append(a);
      argString.append(' ');
    }
    logger.info("Arguments: " + argString);
    try {
      parser.parseArgument(args);
      if (commandLineOptions.help) {
        // print the list of available options
        parser.printUsage(System.out);
        System.exit(0);
      }
View Full Code Here

    }

    private void parseParameters(final Object action, final String[] parameters) {
        final CmdLineParser parser = new CmdLineParser(action);
        try {
            parser.parseArgument(parameters);
        }
        catch (final CmdLineException e) {
            System.err.println(e.getMessage());
            parser.printUsage(System.out);
            System.exit(2);
View Full Code Here

     */

    CommandLineOptions commandLineOptions = new CommandLineOptions();
    CmdLineParser parser = new CmdLineParser(commandLineOptions);
    try {
      parser.parseArgument(args);
    } catch (CmdLineException e) {
      err.printf("Error during command-line parsing: %s%n", e.getLocalizedMessage());
      commandLineOptions.help = true;
    }

View Full Code Here

      }
    });
    CmdLineParser parser = new CmdLineParser(Options.instance);
    Util.setMinecraftDirectory();
    try {
      parser.parseArgument(args);
    } catch (CmdLineException e) {
      Log.w("There was an issue parsing command line options.");
      e.printStackTrace();
    }
   
View Full Code Here

   
  public void testParseSuccess() throws Exception {
       
        TestBean bean = new TestBean();
        CmdLineParser parser = new CmdLineParser(bean);
        parser.parseArgument("-pattern", ".*");
       
    assertEquals(Pattern.compile(".*").toString(), bean.pattern.toString());
  }
   
   
View Full Code Here

            Locale old = Locale.getDefault();
            Locale.setDefault(Locale.ENGLISH);
            TestBean bean = new TestBean();
            CmdLineParser parser = new CmdLineParser(bean);
            try {
                parser.parseArgument("-pattern", "*");
                fail("Expecting exception");
            }
            catch (CmdLineException e) {
                assertEquals("\"-pattern\" must be a regular expression", e.getMessage());
            }
View Full Code Here

    public void testParseWithDefault() throws Exception {

        TestBean bean = new TestBean();

        CmdLineParser parser = new CmdLineParser(bean);
        parser.parseArgument("test1", "test2", "test3");

        Assert.assertEquals(Arrays.asList("def1", "def2", "def3"), Arrays.asList(bean.stringArray));
        Assert.assertEquals(Arrays.asList("test1", "test2", "test3"), Arrays.asList(bean.rest));
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.