Package org.apache.commons.cli2.option

Examples of org.apache.commons.cli2.option.Command


      .withOption(maxOpt)
      .withOption(fieldOpt)
      .create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
View Full Code Here


                obuilder
                        .withShortName("r")
                        .withLongName("recursive")
                        .withDescription("do recursively")
                        .create();
        Command update =
                cbuilder
                        .withName("update")
                        .withName("up")
                        .withDescription("update the work directory")
                        /*
 
View Full Code Here

        if (preferredName == null) {
            throw new IllegalStateException(ResourceHelper.getResourceHelper().getMessage(ResourceConstants.OPTION_NO_NAME));
        }

        // build the command
        final Command option =
            new Command(preferredName, description, aliases, required, argument, children, id);

        // reset the builder
        reset();

        return option;
View Full Code Here

  private static void parseCommand(String[] args)
  {
    Parser parser = new Parser();

    // configure a HelpFormatter
    HelpFormatter hf = new HelpFormatter();
    DefaultOptionBuilder oBuilder = new DefaultOptionBuilder();
    ;

    // configure a parser
    Parser p = new Parser();
View Full Code Here

        "Default Configuration File").withArgument(defaultFile).create());

    gBuilder.withOption(oBuilder.reset().withId(OPTION_G).withShortName("g").withLongName("genconf").withDescription(
        "Generate configuration file from pid").withArgument(pid2).create());

    FileValidator fValidator = VFSFileValidator.getExistingFileInstance().setBase(".");
    fValidator.setFile(false);
    // fValidator.setReadable(true);
    gBuilder.withOption(aBuilder.reset().withName(CONF_FILE).withDescription("is the wrapper.conf to use.  Name must be absolute or relative")
        .withMinimum(0).withMaximum(10).create());

    Validator pValidator = new Validator()
View Full Code Here

        if ((isExisting() && !f.exists()) || (isFile() && !f.getType().equals(FileType.FILE))
            || (isDirectory() && !f.getType().equals(FileType.FILE)) || (isHidden() && !f.isHidden())
            || (isReadable() && !f.isReadable()) || (isWritable() && !f.isWriteable()))
        {

          throw new InvalidArgumentException(name);
        }

        i.set(name);
      }
      catch (Exception ex)
      {
        ex.printStackTrace();
        throw new InvalidArgumentException(name);
      }
    }
  }
View Full Code Here

        for (Iterator it = values.iterator(); it.hasNext();)
        {
          String p = (String) it.next();
          if (!Pattern.matches("wrapper\\..*=.*", p))
          {
            throw new InvalidArgumentException(p);
          }
        }

      }

View Full Code Here

        // Note : This code doesnt belong here, it should be changed to
        // an can exec check in java 6
        for (String file : (List<String>)values) {
          File f = new File(file)
          if ( ! f.exists() ) {
            throw new InvalidArgumentException("Argument : " +
                f.getAbsolutePath() + " doesn't exist.");
          }
          if ( ! f.isFile() ) {
            throw new InvalidArgumentException("Argument : " +
                f.getAbsolutePath() + " is not a file.");
          }
          if ( ! f.canRead() ) {
            throw new InvalidArgumentException("Argument : " +
                f.getAbsolutePath() + " is not accessible");
          }
        }
      }     
    };
View Full Code Here

    fValidator.setFile(false);
    // fValidator.setReadable(true);
    gBuilder.withOption(aBuilder.reset().withName(CONF_FILE).withDescription("is the wrapper.conf to use.  Name must be absolute or relative")
        .withMinimum(0).withMaximum(10).create());

    Validator pValidator = new Validator()
    {

      public void validate(List values) throws InvalidArgumentException
      {
        for (Iterator it = values.iterator(); it.hasNext();)
View Full Code Here

    return builder.withLongName(name).withDescription(desc).create();
  }
 
  private void setupOptions(){

    final Validator fileValidator = new Validator(){
      public void validate(final List values) throws InvalidArgumentException {
        // Note : This code doesnt belong here, it should be changed to
        // an can exec check in java 6
        for (String file : (List<String>)values) {
          File f = new File(file)
          if ( ! f.exists() ) {
            throw new InvalidArgumentException("Argument : " +
                f.getAbsolutePath() + " doesn't exist.");
          }
          if ( ! f.isFile() ) {
            throw new InvalidArgumentException("Argument : " +
                f.getAbsolutePath() + " is not a file.");
          }
          if ( ! f.canRead() ) {
            throw new InvalidArgumentException("Argument : " +
                f.getAbsolutePath() + " is not accessible");
          }
        }
      }     
    };

    // Note: not extending CLI2's FileValidator, that overwrites
    // the String arg into File and causes ClassCastException
    // in inheritance tree.
    final Validator execValidator = new Validator(){
      public void validate(final List values) throws InvalidArgumentException {
        // Note : This code doesnt belong here, it should be changed to
        // an can exec check in java 6
        for (String file : (List<String>)values) {
          try{
View Full Code Here

TOP

Related Classes of org.apache.commons.cli2.option.Command

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.