lindegroup/autopkgr — pull request #123 by eahrold (2014-09-06 21:37:10+00:00)
Title: Auto pkg task class

I've got everything migrated to LGAutoPkgTask class.
I think you'll find it's going to prove much cleaner and easier to use.

creating a task is super easy and extremely flexible,

```Objective-c
LGAutoPkgTask *task = [[LGAutoPkgTask alloc] init];
task.arguments = @[ @"repo-update",@"all" ]; // or anything you would pass to autopkg
// or //
task.arguments = @[@"list-recipes"];

```
Then you can either do an async call that is spawned on a background operation queue
```Objective-c
[task launchInBackground:^(NSError *error) {
NSArray *results;
if(!error){
results = [task results];
}
reply (results,error);
}];
```
or do a blocking call
```Objective-c
NSError *error;
if(![task launch:&error]) {
NSLog(@"%@",error)
}else{
NSLog(@"%@",task.results)
}
```
where task.results is an id based on the autopkg verb type, (either NSArray or NSDictionary)

you can also easily pull the stderr or stdout strings and format them however you so choose.
```Objective-c
NSString *out = task.standardErrString
NSString *err = task.standardOutString;
```

Them most common autopkg operations have included class methods for convince
```Objective-c
+(void)runRecipeList:(NSString *)recipeList
progress:(void (^)(NSString *message, double taskProgress))progress
reply:(void (^)(NSDictionary* report,NSError* error))reply;

+(void)runRecipes:(NSArray *)recipes
progress:(void (^)(NSString *message))progress
reply:(void (^)(NSError* error))reply;

+(void)search:(NSString *)recipe
reply:(void (^)( NSArray *results ,NSError* error))reply;

+(void)makeOverride:(NSString *)recipe
reply:(void (^)(NSError* error))reply;

+(void)listRecipes:(void (^)(NSArray *recipes, NSError* error))reply;
+(NSArray *)listRecipes;

#pragma mark -- Repo methods
+(void)repoAdd:(NSString *)repo
reply:(void (^)(NSError* error))reply;

+(void)repoRemove:(NSString *)repo
reply:(void (^)(NSError *error))reply;

+(void)repoUpdate:(void (^)(NSError *error))reply;

+(void)repoList:(void (^)(NSArray *repos, NSError* error))reply;

#pragma mark -- Other
+(NSString *)version;
```

I've started to do the doc strings, and will flesh those out when time permits.
I think once you start using this during development you'll really enjoy how clean the code is