diff --git a/TodoTxtMac/TTMAppController.h b/TodoTxtMac/TTMAppController.h old mode 100644 new mode 100755 index 1a9208f..fa699ae --- a/TodoTxtMac/TTMAppController.h +++ b/TodoTxtMac/TTMAppController.h @@ -94,6 +94,21 @@ extern NSString *const TodoFileArgument; */ - (NSString*)commandLineArgumentTodoFile; +/*! + * @method openDoneFileFromCommandLineArgument: + * @abstract This method opens a done.txt file based on the command line argument. + * The name of the argument is defined in the DoneFileArgument constant. + * If there is no command line argument, this method does nothing. + */ +- (void)openDoneFileFromCommandLineArgument; + +/*! + * @method commandLineArgumentDoneFile: + * @abstract This method returns the value of the done-file command line argument. + * If there is no command-line argument, it returns null. + */ +- (NSString*)commandLineArgumentDoneFile; + /*! * @method openDocumentFromFilePath: * @abstract This method opens a todo.txt file (TTMDocument) based on a file path. diff --git a/TodoTxtMac/TTMAppController.m b/TodoTxtMac/TTMAppController.m old mode 100644 new mode 100755 index b79ceea..60bfc02 --- a/TodoTxtMac/TTMAppController.m +++ b/TodoTxtMac/TTMAppController.m @@ -129,6 +129,7 @@ @implementation TTMAppController // Constants for command-line argument names NSString *const TodoFileArgument = @"todo-file"; +NSString *const DoneFileArgument = @"done-file"; - (id)init { self = [super init]; @@ -195,11 +196,24 @@ - (void)openTodoFileFromCommandLineArgument { [self openDocumentFromFilePath:fileToOpenOnLaunch]; } +- (void)openDoneFileFromCommandLineArgument { + NSString *fileToOpenOnLaunch = [self commandLineArgumentDoneFile]; + if (!fileToOpenOnLaunch) { + return; + } + [self openDocumentFromFilePath:fileToOpenOnLaunch]; +} + - (NSString*)commandLineArgumentTodoFile { NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; return [args stringForKey:TodoFileArgument]; } +- (NSString*)commandLineArgumentDoneFile { + NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; + return [args stringForKey:DoneFileArgument]; +} + - (void)openDocumentFromFilePath:(NSString*)filePath { NSURL *fileURL = [NSURL fileURLWithPath:filePath]; [self openDocumentFromFileURL:fileURL]; diff --git a/TodoTxtMac/TTMAppDelegate.m b/TodoTxtMac/TTMAppDelegate.m old mode 100644 new mode 100755 index e799c2e..0afe2ff --- a/TodoTxtMac/TTMAppDelegate.m +++ b/TodoTxtMac/TTMAppDelegate.m @@ -53,9 +53,12 @@ @implementation TTMAppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)notification { [self.appController initializeUserDefaults:self]; - // Open file from command line argument. Does nothing if there is no command line argument. + // Open todo file from command line argument. Does nothing if there is no command line argument. [self.appController openTodoFileFromCommandLineArgument]; + // Open done file from command line argument. Does nothing if there is no command line argument. + [self.appController openDoneFileFromCommandLineArgument]; + // Open default todo file, if one is selected and the option is enabled. [self.appController openDefaultTodoFile]; } @@ -67,6 +70,7 @@ - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { // Without this method override, opening a todo file using the command line argument // or the default todo file user preference also opens an Untitled document every time. return ([self.appController commandLineArgumentTodoFile] == NULL && + [self.appController commandLineArgumentDoneFile] == NULL && ![[NSUserDefaults standardUserDefaults] boolForKey:@"openDefaultTodoFileOnStartup"]); }