From 1a0e169e7fa39cfb07b69868ef8a70797d0d4cc8 Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 11 Aug 2016 20:58:53 -0400 Subject: [PATCH] Improve displaying release notes in sparkle-cli (safer & less code) --- sparkle-cli/SPUCommandLineUserDriver.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sparkle-cli/SPUCommandLineUserDriver.m b/sparkle-cli/SPUCommandLineUserDriver.m index a531a6e7..512308ea 100644 --- a/sparkle-cli/SPUCommandLineUserDriver.m +++ b/sparkle-cli/SPUCommandLineUserDriver.m @@ -120,18 +120,24 @@ }); } +- (void)displayReleaseNotes:(const char * _Nullable)releaseNotes +{ + if (releaseNotes != NULL) { + fprintf(stderr, "Release notes:\n"); + fprintf(stderr, "%s\n", releaseNotes); + } +} + - (void)displayHTMLReleaseNotes:(NSData *)releaseNotes { NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTML:releaseNotes documentAttributes:NULL]; - fprintf(stderr, "Release notes:\n"); - fprintf(stderr, "%s\n", attributedString.string.UTF8String); + [self displayReleaseNotes:attributedString.string.UTF8String]; } - (void)displayPlainTextReleaseNotes:(NSData *)releaseNotes encoding:(NSStringEncoding)encoding { NSString *string = [[NSString alloc] initWithData:releaseNotes encoding:encoding]; - fprintf(stderr, "Release notes:\n"); - fprintf(stderr, "%s\n", string.UTF8String); + [self displayReleaseNotes:string.UTF8String]; } - (void)showUpdateWithAppcastItem:(SUAppcastItem *)appcastItem updateAdjective:(NSString *)updateAdjective