DDGetoptLongParser Class Reference

List of all members.


Detailed Description

A command line option parser implemented using getopt_long(3).

In order to simplify usage, this class drives the option parsing by running the while loop. When an option is found, Key-Value Coding (KVC) is used to set a key on the target class. Unless overridden, the key to use is the same as the long option. The long option is converted to camel case, if needed. For example the option "long-option" has a default key of "longOption".

See also:
DDGetoptOption
Examples:

example.m, and simple.m.


Public Member Functions

(id) - initWithTarget:
 Create an option parser with the given target.
(id) - target
 Returns the target object.
(void) - setTarget:
 Sets the target object.
(void) - setGetoptLongOnly:
 If set to YES, parses options with getopt_long_only() instead of getopt_long().
(void) - addOptionsFromTable:
 Add all options from a null terminated option table.
(void) - addLongOption:shortOption:key:argumentOptions:
 Add an option with both long and short options.
(void) - addLongOption:key:argumentOptions:
 Add an option with no short option.
(NSArray *) - parseOptions
 Parse the options using the arguments and command name from NSProcessInfo.
(NSArray *) - parseOptionsWithArguments:command:
 Parse the options on an array of arguments.

Static Public Member Functions

(DDGetoptLongParser *) + optionsWithTarget:
 Create an autoreleased option parser with the given target.

Member Function Documentation

+ (DDGetoptLongParser *) optionsWithTarget: (id)  target  

Create an autoreleased option parser with the given target.

Parameters:
target Object that receives target messages.

- (id) initWithTarget: (id)  target  

Create an option parser with the given target.

Parameters:
target Object that receives target messages.

- (id) target  

Returns the target object.

Returns:
The target object

- (void) setTarget: (id)  target  

Sets the target object.

Parameters:
target The target object

- (void) setGetoptLongOnly: (BOOL)  getoptLongOnly  

If set to YES, parses options with getopt_long_only() instead of getopt_long().

Parameters:
getoptLongOnly YES means parse with getopt_long_only()

- (void) addOptionsFromTable: (DDGetoptOption *)  optionTable  

Add all options from a null terminated option table.

The final entry in the table should contain a nil long option and a null short option.

Parameters:
optionTable An array of DDGetoptOption.

- (void) addLongOption: (NSString *)  longOption
shortOption: (char)  shortOption
key: (NSString *)  key
argumentOptions: (DDGetoptArgumentOptions argumentOptions 

Add an option with both long and short options.

The long option should not contain the double dash ("--"). If you do not want a short option, set it to the zero or the null character.

Parameters:
longOption The long option
shortOption The short option
key The key use when the option is parsed
argumentOptions Options for this options argument

- (void) addLongOption: (NSString *)  longOption
key: (NSString *)  key
argumentOptions: (DDGetoptArgumentOptions argumentOptions 

Add an option with no short option.

Parameters:
longOption The long option
key The key use when the option is parsed
argumentOptions Options for this options argument

- (NSArray *) parseOptions  

Parse the options using the arguments and command name from NSProcessInfo.

Returns:
Arguments left over after option parsing or nil

- (NSArray *) parseOptionsWithArguments: (NSArray *)  arguments
command: (NSString *)  command 

Parse the options on an array of arguments.

Parameters:
arguments Array of command line arguments
command Command name to use for error messages.
Returns:
Arguments left over after option processing or nil


Generated by  doxygen