Index: utils/objfw-new/NewClass.m ================================================================== --- utils/objfw-new/NewClass.m +++ utils/objfw-new/NewClass.m @@ -23,11 +23,11 @@ #import "OFString.h" #import "OFOpenItemFailedException.h" void -newClass(OFString *name) +newClass(OFString *name, OFString *superclass) { OFString *headerPath = [name stringByAppendingPathExtension: @"h"]; OFString *implPath = [name stringByAppendingPathExtension: @"m"]; OFFile *headerFile, *implFile; @try { @@ -40,15 +40,18 @@ [OFStdErr writeFormat: @"File %@ already exists! Aborting...\n", e.path]; [OFApplication terminateWithStatus: 1]; } + if (superclass == nil) + superclass = @"OFObject"; + [headerFile writeFormat: @"#import \n" @"\n" - @"@interface %@: OFObject\n" + @"@interface %@: %@\n" @"@end\n", - name]; + name, superclass]; [implFile writeFormat: @"#import \"%@\"\n" @"\n" @"@implementation %@\n" @"@end\n", Index: utils/objfw-new/ObjFWNew.m ================================================================== --- utils/objfw-new/ObjFWNew.m +++ utils/objfw-new/ObjFWNew.m @@ -24,11 +24,11 @@ @interface ObjFWNew: OFObject @end extern void newApp(OFString *); -extern void newClass(OFString *); +extern void newClass(OFString *, OFString *); OF_APPLICATION_DELEGATE(ObjFWNew) static void showUsage(void) @@ -41,31 +41,37 @@ @implementation ObjFWNew - (void)applicationDidFinishLaunching { bool app, class; + OFString *superclass = nil; const OFOptionsParserOption options[] = { { '\0', @"app", 0, &app, NULL }, { '\0', @"class", 0, &class, NULL }, + { '\0', @"superclass", 1, NULL, &superclass }, { '\0', nil, 0, NULL, NULL } }; OFOptionsParser *optionsParser; OFUnichar option; optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') - if (option == '?') + if (option == '?' || option == ':' || option == '=') showUsage(); if ((app ^ class) != 1 || optionsParser.remainingArguments.count != 1) showUsage(); + if (superclass && !class) + showUsage(); + if (app) newApp(optionsParser.remainingArguments.firstObject); else if (class) - newClass(optionsParser.remainingArguments.firstObject); + newClass(optionsParser.remainingArguments.firstObject, + superclass); else showUsage(); [OFApplication terminate]; } @end