Turns out you can use node.js for Xcode User Scripts.
For example, here’s a script that takes .h property declarations on the clipboard:
@property(retain) NSManagedObjectModel *model;
@property(retain) NSPersistentStoreCoordinator *coordinator;
@property(retain) NSPersistentStore *store;
@property(retain) NSManagedObjectContext *moc;
And outputs their .m @synthesize counterparts:
@synthesize model;
@synthesize coordinator;
@synthesize store;
@synthesize moc;
I’ll skip the bile-laced rant about this required duplication for now.
Here’s the script:
#!/usr/local/bin/node
require('child_process').exec('pbpaste', function(err, stdout){
// collapse newlines
var out = stdout.replace(/\n\n+/gm, '\n');
// rewrite declarations
out = out.replace(/.*?(\w+);/g, '@synthesize $1;');
require('util').puts(out.trim());
});
Update: Kevin Ballard ported the script to Lua.