Skip to content

Commit

Permalink
Add argument for ignoring entities
Browse files Browse the repository at this point in the history
during class generation
  • Loading branch information
Martin Kim Dung-Pham committed Sep 24, 2018
1 parent aaea23b commit b10ff4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions mogenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
NSString *baseClass;
NSString *baseClassImport;
NSString *baseClassForce;
NSString *ignoredEntities;
NSString *includem;
NSString *includeh;
NSString *templatePath;
Expand Down
10 changes: 10 additions & 0 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ - (void)application:(DDCliApplication*)app
{@"base-class", 0, DDGetoptRequiredArgument},
{@"base-class-import", 0, DDGetoptRequiredArgument},
{@"base-class-force", 0, DDGetoptRequiredArgument},
{@"ignored-entities", 0, DDGetoptRequiredArgument},
// For compatibility:
{@"baseClass", 0, DDGetoptRequiredArgument},
{@"includem", 0, DDGetoptRequiredArgument},
Expand Down Expand Up @@ -850,6 +851,7 @@ - (void)printUsage {
"--base-class-force CLASS Same as --base-class except will force all entities to\n"
" have the specified base class. Even if a super entity\n"
" exists\n"
"--ignored-entities LIST Comma separated list of of entity names. Entities will be ignored when generating classes\n"
"--includem FILE Generate aggregate include file for .m files for both\n"
" human and machine generated source files\n"
"--includeh FILE Generate aggregate include file for .h files for human\n"
Expand Down Expand Up @@ -1046,6 +1048,11 @@ - (void)validateOutputPath:(NSString*)path forType:(NSString*)type
}
}

- (BOOL)isIgnoredEntity:(NSString *)entityName {
NSArray<NSString *> *entities = [ignoredEntities componentsSeparatedByString:@","];
return [entities containsObject:entityName] || [entities containsObject:[NSString stringWithFormat:@"_%@", entityName]];
}

- (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments {
if (_help) {
[self printUsage];
Expand Down Expand Up @@ -1192,6 +1199,9 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments {
NSArray *entitiesWithCustomSubclass = [model entitiesWithACustomSubclassInConfiguration:configuration verbose:YES];
for (NSEntityDescription *entity in entitiesWithCustomSubclass)
{
if ([self isIgnoredEntity:entity.name]) {
continue;
}
NSString *generatedMachineH = [machineH executeWithObject:entity sender:nil];
NSString *generatedMachineM = [machineM executeWithObject:entity sender:nil];
NSString *generatedHumanH = [humanH executeWithObject:entity sender:nil];
Expand Down

0 comments on commit b10ff4a

Please sign in to comment.