Merge pull request #575 from rgoldberg/574-app-id-value

`appIDValue` to encapsulate `uint64Value`.
This commit is contained in:
Ross Goldberg 2024-10-15 08:11:19 -04:00 committed by GitHub
commit de13ad12f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 5 deletions

View file

@ -33,7 +33,7 @@ extension Mas {
fulfilled: fulfilled:
appLibrary.installedApps.map { installedApp in appLibrary.installedApps.map { installedApp in
firstly { firstly {
storeSearch.lookup(appID: installedApp.itemIdentifier.uint64Value) storeSearch.lookup(appID: installedApp.itemIdentifier.appIDValue)
}.done { storeApp in }.done { storeApp in
guard let storeApp else { guard let storeApp else {
if verbose { if verbose {

View file

@ -44,7 +44,7 @@ extension Mas {
.joined(separator: "\n")) .joined(separator: "\n"))
do { do {
try downloadAll(apps.map(\.installedApp.itemIdentifier.uint64Value)).wait() try downloadAll(apps.map(\.installedApp.itemIdentifier.appIDValue)).wait()
} catch { } catch {
throw error as? MASError ?? .downloadFailed(error: error as NSError) throw error as? MASError ?? .downloadFailed(error: error as NSError)
} }
@ -70,7 +70,7 @@ extension Mas {
let promises = apps.map { installedApp in let promises = apps.map { installedApp in
// only upgrade apps whose local version differs from the store version // only upgrade apps whose local version differs from the store version
firstly { firstly {
storeSearch.lookup(appID: installedApp.itemIdentifier.uint64Value) storeSearch.lookup(appID: installedApp.itemIdentifier.appIDValue)
}.map { result -> (SoftwareProduct, SearchResult)? in }.map { result -> (SoftwareProduct, SearchResult)? in
guard let storeApp = result, installedApp.isOutdatedWhenComparedTo(storeApp) else { guard let storeApp = result, installedApp.isOutdatedWhenComparedTo(storeApp) else {
return nil return nil

View file

@ -7,10 +7,9 @@
// //
import ArgumentParser import ArgumentParser
import Foundation
import PromiseKit import PromiseKit
typealias AppID = UInt64
@main @main
struct Mas: ParsableCommand { struct Mas: ParsableCommand {
static let configuration = CommandConfiguration( static let configuration = CommandConfiguration(
@ -56,3 +55,11 @@ struct Mas: ParsableCommand {
} }
} }
} }
typealias AppID = UInt64
extension NSNumber {
var appIDValue: AppID {
uint64Value
}
}