                
                 guard let log = result.data where result.success else {
                     print(ChangelogParserError.ParseFailed(description: "Parse failed").description)
+                    //return .Failure(.ParseFailed(description: "Parse failed"))
                     exit(EXIT_FAILURE)
                 }
                 

                        exit(EXIT_FAILURE)
                    }
                    
                    if let tickets = self.getTicketIds(log) where showIssues {

                        self.writeIssues(tickets, file: "CHANGELOG-ISSUES.TXT", completion: { (writeIssuesResult) in
                            
                            if let error = writeIssuesResult.error where !writeIssuesResult.success {
                                print(error.description)
                                exit(EXIT_FAILURE)
                            }
                            exit(EXIT_SUCCESS)
                        })
                        
                    } else {
                        exit(EXIT_SUCCESS)
                    }
                    
                    
                })
                exit(EXIT_SUCCESS)
            })

            
        } catch let error as NSError {
            
            print(ChangelogParserError.ParseFailed(description: error.localizedDescription).description)
            exit(EXIT_FAILURE)
        }
        
        CFRunLoopRun()
        return .Failure(.ParseFailed(description: "Parse failed"))
    }
    
    /// Write a `Changelog` to the provided file on disk.

            completion(result: ChangelogParserResult(success: false, error: .FileWriteFailed(description: "Write to output file \(outUrl) failed: \(error.localizedDescription)"), data: nil))
        }
    }
    
    /// Write Version to a file on disk.
    private func writeVersion(version: String, build:String, file: String, completion: (result: ChangelogParserResult) -> ()) {
        
        guard let outUrl:NSURL = NSURL.init(fileURLWithPath: file) else {
            completion(result: ChangelogParserResult(success: false, error: .FileWriteFailed(description: "Write to output file failed"), data: nil))
            return
        }
        
        do {
            let text = version + " #" + build
            try text.writeToURL(outUrl, atomically: false, encoding: NSUTF8StringEncoding)
            completion(result: ChangelogParserResult(success: true, error: nil, data: nil))
            
        } catch let error as NSError {
            completion(result: ChangelogParserResult(success: false, error: .FileWriteFailed(description: "Write to output file \(outUrl) failed: \(error.localizedDescription)"), data: nil))
        }
    }
    
    /// Build a string with 'Version: x.y.z Number: buildnumber'
    private func buildInfo(log: Changelog) -> String {
        
        guard let buildVersion:String = log.version, let buildNumber:UInt = log.buildNumber, let buildString:String = String(buildNumber) else {
            return ""
        }
        
        return "Version: \(buildVersion) Number:\(buildString)"
    }

}

