Package org.apache.commons.cli

Examples of org.apache.commons.cli.BasicParser


  // Not for client use
  public boolean config(String... args) {
   
    CommandLine cl;
    try {
      cl = new BasicParser().parse(opts, args);
      if (cl.getArgs().length > 0)
        throw new ParseException("Unrecognized arguments: " + cl.getArgList());
     
      if (cl.hasOption(helpOpt.getOpt())) {
        configError = true;
View Full Code Here


       
        // Get the options from the command on how to parse the string
        Options parseOpts = sc.getOptionsWithHelp();
       
        // Parse the string using the given options
        CommandLine cl = new BasicParser().parse(parseOpts, fields);
       
        int actualArgLen = cl.getArgs().length;
        int expectedArgLen = sc.numArgs();
        if (cl.hasOption(helpOption)) {
          // Display help if asked to; otherwise execute the command
View Full Code Here

    IOException {
    // verify we have args at all (can't run without them!)
    if (args.length == 0) {
      throw new IllegalArgumentException("No arguments were provided (try -h)");
    }
    CommandLineParser parser = new BasicParser();
    CommandLine cmd = parser.parse(OPTIONS, args);

    // simply printing help or info, return normally but kill job run
    if (cmd.hasOption("h")) {
      printHelp();
      return null;
View Full Code Here

  // Not for client use
  public boolean config(String... args) {
   
    CommandLine cl;
    try {
      cl = new BasicParser().parse(opts, args);
      if (cl.getArgs().length > 0)
        throw new ParseException("Unrecognized arguments: " + cl.getArgList());
     
      if (cl.hasOption(helpOpt.getOpt())) {
        configError = true;
View Full Code Here

       
        // Get the options from the command on how to parse the string
        Options parseOpts = sc.getOptionsWithHelp();
       
        // Parse the string using the given options
        CommandLine cl = new BasicParser().parse(parseOpts, fields);
       
        int actualArgLen = cl.getArgs().length;
        int expectedArgLen = sc.numArgs();
        if (cl.hasOption(helpOption)) {
          // Display help if asked to; otherwise execute the command
View Full Code Here

  }

  protected CommandLine parseArgs(String[] args) throws ParseException {
    options.addOption(SHORT_HELP_OPTION, LONG_HELP_OPTION, false, "Show usage");
    addOptions();
    CommandLineParser parser = new BasicParser();
    return parser.parse(options, args);
  }
View Full Code Here

    private CommandLineParser parser;

    public StockApplet() {
        options = new Options();
        options.addOption("v", false, "verbose");
        parser = new BasicParser();
    }
View Full Code Here

  /**
   * Parse the command line arguments.
   */
  void parseArguments(String[] args) {
    CommandLineParser parser = new BasicParser();
    CommandLine commandLine = null;
    try {
      commandLine = parser.parse(options, args);
    } catch (org.apache.commons.cli.ParseException e) {
      System.err.println("Could not parse arguments correctly.");
      usage(true);
    }

View Full Code Here

        options.addOption("credFile", true, "Import option with -preserveOwnership, this is a properties file mapping with user=pass");
        options.addOption("stripSignatures", false, "Im/Export option, removes digital signatures from all signed items, default is false");


        // create the parser
        CommandLineParser parser = new BasicParser();
        CommandLine line = null;
        try {
            // parse the command line arguments
            line = parser.parse(options, args);

            if (line.hasOption("import") && line.hasOption("export")) {
                ShowHelp(options);
                return;
            }
View Full Code Here

      options.addOption(option);

    }

    Parser createParser() {
      Parser result = new BasicParser();
      return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.BasicParser

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.