Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Sources/MAS/Commands/Lucky.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ extension MAS {

private func run(downloader: Downloader, installedApps: [InstalledApp], searcher: AppStoreSearcher) async throws {
let searchTerm = searchTermOptionGroup.searchTerm
let results = try await searcher.search(for: searchTerm)
guard let result = results.first else {
guard let result = try await searcher.search(for: searchTerm).first else {
throw MASError.noSearchResultsFound(for: searchTerm)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/MAS/Controllers/AppStoreSearcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protocol AppStoreSearcher {
/// - searchTerm: Term for which to search.
/// - region: The ISO 3166-1 region alpha-2 of the storefront in which to
/// search for apps.
/// - Returns: An `Array` of `SearchResult`s matching `searchTerm`.
/// - Returns: A `[SearchResult]` matching `searchTerm`.
/// - Throws: An `Error` if any problem occurs.
func search(for searchTerm: String, inRegion region: String) async throws -> [SearchResult]
}
Expand All @@ -43,7 +43,7 @@ extension AppStoreSearcher {
/// Searches for apps.
///
/// - Parameter searchTerm: Term for which to search.
/// - Returns: An `Array` of `SearchResult`s matching `searchTerm`.
/// - Returns: A `[SearchResult]` matching `searchTerm`.
/// - Throws: An `Error` if any problem occurs.
func search(for searchTerm: String) async throws -> [SearchResult] {
try await search(for: searchTerm, inRegion: await region)
Expand Down
5 changes: 2 additions & 3 deletions Sources/MAS/Controllers/ITunesSearchAppStoreSearcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ struct ITunesSearchAppStoreSearcher: AppStoreSearcher {
/// - Throws: A `MASError.unknownAppID(appID)` if `appID` is invalid.
/// Some other `Error` if any other problem occurs.
func lookup(appID: AppID, inRegion region: String) async throws -> SearchResult {
let results = try await getSearchResults(from: try lookupURL(forAppID: appID, inRegion: region))
guard let result = results.first else {
guard let result = try await getSearchResults(from: try lookupURL(forAppID: appID, inRegion: region)).first else {
throw MASError.unknownAppID(appID)
}

Expand All @@ -44,7 +43,7 @@ struct ITunesSearchAppStoreSearcher: AppStoreSearcher {
/// - searchTerm: Term for which to search.
/// - region: The ISO 3166-1 region alpha-2 of the storefront in which to
/// search for apps.
/// - Returns: An `Array` of `SearchResult`s matching `searchTerm`.
/// - Returns: A `[SearchResult]` matching `searchTerm`.
/// - Throws: An `Error` if any problem occurs.
func search(for searchTerm: String, inRegion region: String) async throws -> [SearchResult] {
try await getSearchResults(from: try searchURL(for: searchTerm, inRegion: region))
Expand Down