Created
April 8, 2014 12:40
-
-
Save Daij-Djan/10118100 to your computer and use it in GitHub Desktop.
plutilIdent: tiny quick&dirty (very) utility that checks if two given plists/strings files contain equal keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// plutilIdent | |
// | |
// Created by Dominik Pich on 08/04/14. | |
// Copyright (c) 2014 Dominik Pich. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
if(argc!=3) { | |
NSLog(@"missing args: plist1 plist2"); | |
return -1; | |
} | |
//read plist1 | |
NSDictionary *plist1; | |
@try { | |
id path = [@(argv[1]) stringByExpandingTildeInPath]; | |
plist1 = [NSDictionary dictionaryWithContentsOfFile:path]; | |
if(!plist1) { | |
NSLog(@"Cant open %@", path); | |
return -1; | |
} | |
} | |
@catch (NSException *exception) { | |
NSLog(@"Failed to parse plist1"); | |
return -1; | |
} | |
//read plist2 | |
NSDictionary *plist2; | |
@try { | |
id path = [@(argv[2]) stringByExpandingTildeInPath]; | |
plist2 = [NSDictionary dictionaryWithContentsOfFile:path]; | |
if(!plist2) { | |
NSLog(@"Cant open %@", path); | |
return -1; | |
} | |
} | |
@catch (NSException *exception) { | |
NSLog(@"Failed to parse plist2"); | |
return -1; | |
} | |
//check 1>2 | |
for (NSString *key in plist1.allKeys) { | |
if(![plist2 objectForKey:key]) { | |
NSLog(@"not in plist2: %@", key); | |
} | |
} | |
//check 2>1 | |
for (NSString *key in plist2.allKeys) { | |
if(![plist1 objectForKey:key]) { | |
NSLog(@"not in plist1: %@", key); | |
} | |
} | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment