diff --git a/Sources/mas/Commands/Upgrade.swift b/Sources/mas/Commands/Upgrade.swift index 4823976..21ec1ba 100644 --- a/Sources/mas/Commands/Upgrade.swift +++ b/Sources/mas/Commands/Upgrade.swift @@ -35,7 +35,6 @@ extension MAS { } guard !apps.isEmpty else { - printWarning("Nothing found to upgrade") return } @@ -59,14 +58,22 @@ extension MAS { let apps = appIDOrNames.isEmpty ? appLibrary.installedApps - : appIDOrNames.flatMap { appID in - if let appID = AppID(appID) { + : appIDOrNames.flatMap { appIDOrName in + if let appID = AppID(appIDOrName) { // argument is an AppID, lookup apps by id using argument - return appLibrary.installedApps(withAppID: appID) + let installedApps = appLibrary.installedApps(withAppID: appID) + if installedApps.isEmpty { + printError("Unknown app ID \(appID)") + } + return installedApps } // argument is not an AppID, lookup apps by name using argument - return appLibrary.installedApps(named: appID) + let installedApps = appLibrary.installedApps(named: appIDOrName) + if installedApps.isEmpty { + printError("Unknown app name '\(appIDOrName)'") + } + return installedApps } let promises = apps.map { installedApp in diff --git a/Tests/masTests/Commands/UpgradeSpec.swift b/Tests/masTests/Commands/UpgradeSpec.swift index 6630777..c3a805f 100644 --- a/Tests/masTests/Commands/UpgradeSpec.swift +++ b/Tests/masTests/Commands/UpgradeSpec.swift @@ -25,7 +25,7 @@ public class UpgradeSpec: QuickSpec { .run(appLibrary: MockAppLibrary(), searcher: MockAppStoreSearcher()) } } - == "Warning: Nothing found to upgrade\n" + .toNot(throwError()) } } }