Improve upgrade unknown app ID/name error output.

Don't output a warning if nothing requires an upgrade.

Partial #533

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-29 03:38:12 -04:00
parent 3d264675bf
commit 64ab55718a
No known key found for this signature in database
2 changed files with 13 additions and 6 deletions

View file

@ -35,7 +35,6 @@ extension MAS {
} }
guard !apps.isEmpty else { guard !apps.isEmpty else {
printWarning("Nothing found to upgrade")
return return
} }
@ -59,14 +58,22 @@ extension MAS {
let apps = let apps =
appIDOrNames.isEmpty appIDOrNames.isEmpty
? appLibrary.installedApps ? appLibrary.installedApps
: appIDOrNames.flatMap { appID in : appIDOrNames.flatMap { appIDOrName in
if let appID = AppID(appID) { if let appID = AppID(appIDOrName) {
// argument is an AppID, lookup apps by id using argument // 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 // 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 let promises = apps.map { installedApp in

View file

@ -25,7 +25,7 @@ public class UpgradeSpec: QuickSpec {
.run(appLibrary: MockAppLibrary(), searcher: MockAppStoreSearcher()) .run(appLibrary: MockAppLibrary(), searcher: MockAppStoreSearcher())
} }
} }
== "Warning: Nothing found to upgrade\n" .toNot(throwError())
} }
} }
} }