diff options
author | Teddy Wing | 2018-10-25 21:07:39 +0200 |
---|---|---|
committer | Teddy Wing | 2018-10-25 21:07:39 +0200 |
commit | e461a496b2ad1e22be18cf651fcac7a191089059 (patch) | |
tree | c0882f343e1db76e56e0b7807a458da8302fca20 | |
parent | 6c06b4311ff1e5781d53f777ac00e196038c75e2 (diff) | |
download | DomeKey-e461a496b2ad1e22be18cf651fcac7a191089059.tar.bz2 |
LicenseHandler: Move invalid license error message to a new method
This enables us to print the error message in both of the following
cases:
1. Validating an existing key
2. Adding a new license key
-rw-r--r-- | DomeKey/LicenseHandler.m | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/DomeKey/LicenseHandler.m b/DomeKey/LicenseHandler.m index b18bd77..c6e0e9c 100644 --- a/DomeKey/LicenseHandler.m +++ b/DomeKey/LicenseHandler.m @@ -16,11 +16,7 @@ static NSString * const LICENSE_FILE_NAME = @"license.plist"; { if ([self licenseFileExists]) { if (![self validateLicense]) { - eprintf( - "The license file '%s' is invalid. " - "Try adding your license again using the `--license` flag.\n", - [[[self licensePath] path] UTF8String] - ); + [self printInvalidLicenseMessage]; // TODO: then do trial } @@ -53,6 +49,8 @@ static NSString * const LICENSE_FILE_NAME = @"license.plist"; printf("Thank you for registering DomeKey!\n"); } else { + [self printInvalidLicenseMessage]; + [[NSWorkspace sharedWorkspace] recycleURLs:[NSArray arrayWithObject:[self licensePath]] completionHandler:^(NSDictionary<NSURL *,NSURL *> *newURLs, NSError *error) { @@ -129,4 +127,13 @@ static NSString * const LICENSE_FILE_NAME = @"license.plist"; return validated; } ++ (void)printInvalidLicenseMessage +{ + eprintf( + "The license file '%s' is invalid. " + "Try adding your license again using the `--license` flag.\n", + [[[self licensePath] path] UTF8String] + ); +} + @end |