#import "DDCommandLineInterface.h" @interface SimpleApp : NSObject <DDCliApplicationDelegate> { NSString * _output; BOOL _help; } @end
#import "SimpleApp.h" @implementation SimpleApp - (void) application: (DDCliApplication *) app willParseOptions: (DDGetoptLongParser *) optionsParser; { [optionsParser setGetoptLongOnly: YES]; DDGetoptOption optionTable = { // Long Short Argument options {@"output", 'o', DDGetoptRequiredArgument}, {@"help", 'h', DDGetoptNoArgument}, {nil, 0, 0}, }; [optionsParser addOptionsFromTable: optionTable]; } - (int) application: (DDCliApplication *) app runWithArguments: (NSArray *) arguments; { ddprintf(@"Output: %@, help: %d\n", _output, _help); ddprintf(@"Arguments: %@\n", arguments); return EXIT_SUCCESS; } @end
#import "DDCommandLineInterface.h" #import "SimpleApp.h" int main (int argc, char * const * argv) { return DDCliAppRunWithClass([SimpleApp class]); }