Class CLArgsParser

  • All Implemented Interfaces:

    
    public final class CLArgsParser
    
                        

    Parser for command line arguments. This parses command lines according to the standard (?) of GNU utilities. Note: This is still used in 1.1 libraries so do not add 1.2+ dependencies. Note that CLArgs uses a backing hashtable for the options index and so duplicate arguments are only returned by getArguments().

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Array<String> getUnparsedArgs() Retrieve an array of arguments that have not been parsed due to the parser halting.
      final List<CLOption> getArguments() Retrieve a list of options that were parsed from command list.
      final CLOption getArgumentById(int id) Retrieve the CLOption with specified id, or null if no command line option is found.
      final CLOption getArgumentByName(String name) Retrieve the CLOption with specified name, or null if no command line option is found.
      final String getErrorString() Retrieve an error message that occurred during parsing if one existed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CLArgsParser

        CLArgsParser(Array<String> args, Array<CLOptionDescriptor> optionDescriptors, ParserControl control)
        Create a parser that can deal with options and parses certain args.
        Parameters:
        args - the args, typically that passed to the public static void main(String[] args) method.
        optionDescriptors - the option descriptors
        control - the parser control used determine behaviour of parser
      • CLArgsParser

        CLArgsParser(Array<String> args, Array<CLOptionDescriptor> optionDescriptors)
        Create a parser that deals with options and parses certain args.
        Parameters:
        args - the args
        optionDescriptors - the option descriptors
    • Method Detail

      • getUnparsedArgs

         final Array<String> getUnparsedArgs()

        Retrieve an array of arguments that have not been parsed due to the parser halting.

        Returns:

        an array of unparsed args

      • getArguments

         final List<CLOption> getArguments()

        Retrieve a list of options that were parsed from command list.

        Returns:

        the list of options

      • getArgumentById

         final CLOption getArgumentById(int id)

        Retrieve the CLOption with specified id, or null if no command line option is found.

        Parameters:
        id - the command line option id
        Returns:

        the CLOption with the specified id, or nullif no CLOption is found.

      • getArgumentByName

         final CLOption getArgumentByName(String name)

        Retrieve the CLOption with specified name, or null if no command line option is found.

        Parameters:
        name - the command line option name
        Returns:

        the CLOption with the specified name, or null if no CLOption is found.

      • getErrorString

         final String getErrorString()

        Retrieve an error message that occurred during parsing if one existed.

        Returns:

        the error string