aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-10-25 21:07:39 +0200
committerTeddy Wing2018-10-25 21:07:39 +0200
commite461a496b2ad1e22be18cf651fcac7a191089059 (patch)
treec0882f343e1db76e56e0b7807a458da8302fca20
parent6c06b4311ff1e5781d53f777ac00e196038c75e2 (diff)
downloadDomeKey-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.m17
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