org.apache.commons.cli

Interface CommandLineParser

Known Implementing Classes:
BasicParser, GnuParser, Parser, PosixParser

public interface CommandLineParser

A class that implements the CommandLineParser interface can parse a String array according to the Options specified and return a CommandLine.

Method Summary

CommandLine
parse(Options options, String[] arguments)
Parse the arguments according to the specified options.
CommandLine
parse(Options options, String[] arguments, boolean stopAtNonOption)
Parse the arguments according to the specified options.

Method Details

parse

public CommandLine parse(Options options,
                         String[] arguments)
            throws ParseException
Parse the arguments according to the specified options.
Parameters:
options - the specified Options
arguments - the command line arguments
Returns:
the list of atomic option and value tokens
Throws:
ParseException - if there are any problems encountered while parsing the command line tokens.
Usages and Demos :

View More Examples of parse(Options options,String[] arguments)
   1: import org.apache.commons.cli.CommandLine;
   2: import org.apache.commons.cli.CommandLineParser;
   3: import org.apache.commons.cli.PosixParser;
   4:         ...
   5:       new InputSource(Shell.class.getResourceAsStream(TOOLBOX_XML));
   6:     parser.parse(source, handler);
   7:   }
   8:         ...
   9: 
  10:     CommandLineParser parser = new PosixParser();
  11:     CommandLine line = null;
  12:         ...
  13:     try {
  14:       line = parser.parse(options, args);

View Full Code Here
   1: import org.apache.commons.cli.CommandLine;
   2: import org.apache.commons.cli.CommandLineParser;
   3: import org.apache.commons.cli.HelpFormatter;
   4:         ...
   5:     {
   6:         CommandLineParser parser = new PosixParser();
   7:         ...
   8:         return parser.parse(options, args);
   9:     }

View Full Code Here
   1: import org.apache.commons.cli.CommandLine;
   2: import org.apache.commons.cli.CommandLineParser;
   3: import org.apache.commons.cli.HelpFormatter;
   4:         ...
   5: 
   6:     public String[] checkPassword(CommandLineParser parser, Options options, String[] args, OptionDefinition defHost, OptionDefinition defUser, OptionDefinition defPassword) {
   7:         
   8:         ...
   9:         try {
  10:             parser.parse( options, args);
  11:         } catch (MissingOptionException e) {

View Full Code Here

parse

public CommandLine parse(Options options,
                         String[] arguments,
                         boolean stopAtNonOption)
            throws ParseException
Parse the arguments according to the specified options.
Parameters:
options - the specified Options
arguments - the command line arguments
stopAtNonOption - specifies whether to continue parsing the arguments if a non option is encountered.
Returns:
the list of atomic option and value tokens
Throws:
ParseException - if there are any problems encountered while parsing the command line tokens.