Package com.martiansoftware.jsap

Examples of com.martiansoftware.jsap.JSAPResult.success()


   protected JSAPResult parseParameters(String[] args) throws Exception {
      SimpleJSAP jsap = buildCommandLineOptions();

      JSAPResult config = jsap.parse(args);
      if (!config.success() || jsap.messagePrinted()) {
         Iterator<?> messageIterator = config.getErrorMessageIterator();
         while (messageIterator.hasNext()) System.err.println(messageIterator.next());
         System.err.println(jsap.getHelp());
         return null;
      }
View Full Code Here


public class Main {
    public static void main(String[] args) throws ParserException, IOException, DateTimeException, JSAPException {
        JSAP jsap = new ArgumentsParser();
        JSAPResult config = jsap.parse(args);

        if (!config.success() || config.getBoolean("help")) {
            System.out.println();
            for (Iterator errs = config.getErrorMessageIterator(); errs.hasNext();) {
                System.out.println("Error: " + errs.next());
            }
            System.out.println();
View Full Code Here

    JSAPResult parsedArgs;
    int i = 0;
    while(i < args.length) {
      parsedArgs = argsParser.parse(Arrays.copyOfRange(args, i, args.length));
     
      if(parsedArgs.success()) {
        args = Arrays.copyOfRange(args, 0, i);
        processedParsedArgs(parsedArgs);
        break;
      }
      ++i;
View Full Code Here

  }
 
  private JSAPResult parseArgs(String[] args) throws ArgumentParsingException {
    JSAPResult parsedArgs = argsParser.parse(args);
   
    if(!parsedArgs.success()) {
      List<String> errorMessages = new ArrayList<>();
      Iterator<?> paramsIterator = parsedArgs.getBadParameterIDIterator();
     
      while(paramsIterator.hasNext()) {
        String paramName = (String) paramsIterator.next();
View Full Code Here

    JSAP argsParser = createArgsParser(mode);

    JSAPResult config = argsParser.parse(args);

    boolean success = true;
    if (!config.success())
    {
      throw new CommandArgumentsException("Invalid arguments provided.", testCommand);
    }
    else
    {
View Full Code Here

    app.registerParameter(new FlaggedOption("iterations", AppConfig.POSITIVE_INTEGER_PARSER, "10", false, 'i', "iterations", "Number of iterations to optimize for (default: infinity).").setUsageName("N"));
    app.registerParameter(new Switch("overwrite", AppConfig.NO_SHORTFLAG, "overwrite", "Overwrite output file?"));

    JSAPResult result = app.parse(args);

    if (!result.success())
    {
      for (java.util.Iterator errs = result.getErrorMessageIterator(); errs.hasNext();)
        System.err.println("Error: " + errs.next());

      System.err.println("\nUsage: java " + DemoApp.class.getName());
View Full Code Here

    opt2.setHelp("One or more names of people you would like to greet.");
    jsap.registerParameter(opt2);
   
    JSAPResult config = jsap.parse(args)

    if (!config.success()) {
      System.err.println();
      System.err.println("Usage: java "
                + Manual_HelloWorld_6.class.getName());
      System.err.println("                "
                + jsap.getUsage());
View Full Code Here

        p.setProperty("flagged", "My Flagged Value");
        PropertyDefaultSource pds = new PropertyDefaultSource(p);
        jsap.registerDefaultSource(pds);

        JSAPResult result = jsap.parse("");
        assertTrue(result.success());

        assertEquals(result.getBoolean("testswitch"), true);
        assertEquals(result.getString("testflagged"), "My Flagged Value");

        p.setProperty("unexpected", "jsap won't know what to do with this");
View Full Code Here

        assertEquals(result.getBoolean("testswitch"), true);
        assertEquals(result.getString("testflagged"), "My Flagged Value");

        p.setProperty("unexpected", "jsap won't know what to do with this");
        result = jsap.parse("");
        assertFalse(result.success());

        /*
        for (java.util.Iterator i1 = result.getBadParameterIDIterator(); i1.hasNext(); ) {
            String badID = (String) i1.next();
            for (java.util.Iterator i2 = result.getExceptionIterator(badID); i2.hasNext(); ) {
View Full Code Here

    opt2.setHelp("One or more names of people you would like to greet.");
    jsap.registerParameter(opt2);
   
    JSAPResult config = jsap.parse(args)

    if (!config.success()) {
     
      System.err.println();

      // print out specific error messages describing the problems
      // with the command line, THEN print usage, THEN print full
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.