@@ -25,49 +25,53 @@ @interface ObjFWNew: OFObject @end extern void newApp(OFString *); extern void newClass(OFString *, OFString *, OFMutableArray *); +extern void newTest(OFString *); OF_APPLICATION_DELEGATE(ObjFWNew) static void help(OFStream *stream, bool full, int status) { [stream writeFormat: - @"Usage: %@ --app|--class [--superclass=] [--property=] name\n", + @"Usage: %@ --app|--class|--test [--superclass=] [--property=] name" + @"\n", [OFApplication programName]]; if (full) { [stream writeString: @"\n"]; [stream writeLine: @"Options:\n" @" -a --app Create a new app\n" @" -c --class Create a new class\n" @" -h --help Show this help\n" - @" -s --superclass= Specify the superclass for the " - @"class\n" @" -p --property= Add a property to the class.\n" @" E.g.: --property='(readonly, " - @"nonatomic) id foo'"]; + @"nonatomic) id foo'\n" + @" -s --superclass= Specify the superclass for the " + @"class\n" + @" -t --test Create a new test\n"]; } [OFApplication terminateWithStatus: status]; } @implementation ObjFWNew - (void)applicationDidFinishLaunching: (OFNotification *)notification { - bool app, class; + bool app, class, test; OFString *superclass = nil, *name; OFMutableArray OF_GENERIC(OFString *) *properties = nil; const OFOptionsParserOption options[] = { { 'a', @"app", 0, &app, NULL }, { 'c', @"class", 0, &class, NULL }, { 'h', @"help", 0, NULL, NULL }, - { 's', @"superclass", 1, NULL, &superclass }, { 'p', @"property", 1, NULL, NULL }, + { 's', @"superclass", 1, NULL, &superclass }, + { 't', @"test", 0, &test, NULL }, { '\0', nil, 0, NULL, NULL } }; OFOptionsParser *optionsParser; OFUnichar option; @@ -92,11 +96,12 @@ help(OFStdErr, false, 1); break; } } - if ((app ^ class) != 1 || optionsParser.remainingArguments.count != 1) + if (app + class + test != 1 || + optionsParser.remainingArguments.count != 1) help(OFStdErr, false, 1); if ((superclass && !class) || (properties != nil && !class)) help(OFStdErr, false, 1); @@ -108,11 +113,13 @@ if (app) newApp(name); else if (class) newClass(name, superclass, properties); + else if (test) + newTest(name); else help(OFStdErr, false, 1); [OFApplication terminate]; } @end