Class CmdLineParser


  • public class CmdLineParser
    extends Object
    Largely GNU-compatible command-line options parser. Has short (-v) and long-form (--verbose) option support, and also allows options with associated values (-d 2, --debug 2, --debug=2). Option processing can be explicitly terminated by the argument '--'.
    Version:
    $Revision: 1.10 $
    Author:
    Steve Purcell
    See Also:
    CommandLineInterpreter
    • Constructor Detail

      • CmdLineParser

        public CmdLineParser()
    • Method Detail

      • addStringOption

        public final CmdLineParser.Option addStringOption​(char shortForm,
                                                          String longForm)
        Convenience method for adding a string option.
        Parameters:
        shortForm - The short form for this option
        longForm - The long form for this option
        Returns:
        the new Option
      • addStringOption

        public final CmdLineParser.Option addStringOption​(String longForm)
        Convenience method for adding a string option.
        Parameters:
        longForm - The long form for this option
        Returns:
        the new Option
      • addIntegerOption

        public final CmdLineParser.Option addIntegerOption​(char shortForm,
                                                           String longForm)
        Convenience method for adding an integer option.
        Parameters:
        shortForm - The short form for this option
        longForm - The long form for this option
        Returns:
        the new Option
      • addIntegerOption

        public final CmdLineParser.Option addIntegerOption​(String longForm)
        Convenience method for adding an integer option.
        Parameters:
        longForm - The long form for this option
        Returns:
        the new Option
      • addLongOption

        public final CmdLineParser.Option addLongOption​(char shortForm,
                                                        String longForm)
        Convenience method for adding a long integer option.
        Parameters:
        shortForm - The short form for this option
        longForm - The long form for this option
        Returns:
        the new Option
      • addLongOption

        public final CmdLineParser.Option addLongOption​(String longForm)
        Convenience method for adding a long integer option.
        Parameters:
        longForm - The long form for this option
        Returns:
        the new Option
      • addDoubleOption

        public final CmdLineParser.Option addDoubleOption​(char shortForm,
                                                          String longForm)
        Convenience method for adding a double option.
        Parameters:
        shortForm - The short form for this option
        longForm - The long form for this option
        Returns:
        the new Option
      • addDoubleOption

        public final CmdLineParser.Option addDoubleOption​(String longForm)
        Convenience method for adding a double option.
        Parameters:
        longForm - The long form for this option
        Returns:
        the new Option
      • addBooleanOption

        public final CmdLineParser.Option addBooleanOption​(char shortForm,
                                                           String longForm)
        Convenience method for adding a boolean option.
        Parameters:
        shortForm - The short form for this option
        longForm - The long form for this option
        Returns:
        the new Option
      • addBooleanOption

        public final CmdLineParser.Option addBooleanOption​(String longForm)
        Convenience method for adding a boolean option.
        Parameters:
        longForm - The long form for this option
        Returns:
        the new Option
      • getOptionValues

        public final Vector getOptionValues​(CmdLineParser.Option option)
        Returns:
        A Vector giving the parsed values of all the occurrences of the given Option, or an empty Vector if the option was not set.
      • getRemainingArgs

        public final String[] getRemainingArgs()
        Returns:
        the non-option arguments