Source

PRHTask / PRHTaskTest / PRHTaskTest / main.m

Full commit
Peter Hosey b08dc03 










Peter Hosey fb0493e 
Peter Hosey b08dc03 
Peter Hosey dc6d1af 

Peter Hosey cd11fbc 

Peter Hosey 4e231ff 

Peter Hosey cd11fbc 

Peter Hosey 3f25cc5 
Peter Hosey 4e231ff 
Peter Hosey cbafe9e 

Peter Hosey 3f25cc5 
Peter Hosey cbafe9e 
Peter Hosey cd11fbc 
Peter Hosey b08dc03 

Peter Hosey cbafe9e 

Peter Hosey fb0493e 
Peter Hosey b08dc03 

//
//  main.m
//  PRHTaskTest
//
//  Created by Peter Hosey on 2011-10-13.
//  Copyright 2011 Peter Hosey. All rights reserved.
//

#import "PRHTask.h"

int main (int argc, char **argv) {
	@autoreleasepool {

	//When using the varargs method, strings and arrays of strings can be mixed in the arguments parameter list.
	PRHTask *task = [PRHTask taskWithProgramName:@"echo" arguments:@"I am the very model of a", [NSArray arrayWithObjects:@"modern", @"Major-General", nil], nil];
	task.accumulatesStandardOutput = YES;

	task.successfulTerminationBlock = ^(PRHTask *completedTask) {
		NSLog(@"Completed task: %@ with exit status: %i", completedTask, completedTask.terminationStatus);
		NSLog(@"Accumulated output: %@", [task outputStringFromStandardOutputUTF8]);

		exit(EXIT_SUCCESS);
	};
	task.abnormalTerminationBlock = ^(PRHTask *completedTask) {
		NSLog(@"Task exited abnormally: %@ with exit status: %i", completedTask, completedTask.terminationStatus);
		exit(EXIT_FAILURE);
	};

	[task launch];

	dispatch_main();

	} //@autoreleasepool
	return EXIT_SUCCESS;
}