mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
Rename some uses of appName
as searchTerm
.
Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
0e49da7bf1
commit
0b11f3737c
4 changed files with 7 additions and 7 deletions
|
@ -21,7 +21,7 @@ extension Mas {
|
||||||
@Flag(help: "force reinstall")
|
@Flag(help: "force reinstall")
|
||||||
var force = false
|
var force = false
|
||||||
@Argument(help: "the app name to install")
|
@Argument(help: "the app name to install")
|
||||||
var appName: String
|
var searchTerm: String
|
||||||
|
|
||||||
/// Runs the command.
|
/// Runs the command.
|
||||||
func run() throws {
|
func run() throws {
|
||||||
|
@ -32,7 +32,7 @@ extension Mas {
|
||||||
var appID: AppID?
|
var appID: AppID?
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let results = try storeSearch.search(for: appName).wait()
|
let results = try storeSearch.search(for: searchTerm).wait()
|
||||||
guard let result = results.first else {
|
guard let result = results.first else {
|
||||||
printError("No results found")
|
printError("No results found")
|
||||||
throw MASError.noSearchResultsFound
|
throw MASError.noSearchResultsFound
|
||||||
|
|
|
@ -20,7 +20,7 @@ extension Mas {
|
||||||
@Flag(help: "Show price of found apps")
|
@Flag(help: "Show price of found apps")
|
||||||
var price = false
|
var price = false
|
||||||
@Argument(help: "the app name to search")
|
@Argument(help: "the app name to search")
|
||||||
var appName: String
|
var searchTerm: String
|
||||||
|
|
||||||
func run() throws {
|
func run() throws {
|
||||||
try run(storeSearch: MasStoreSearch())
|
try run(storeSearch: MasStoreSearch())
|
||||||
|
@ -28,7 +28,7 @@ extension Mas {
|
||||||
|
|
||||||
func run(storeSearch: StoreSearch) throws {
|
func run(storeSearch: StoreSearch) throws {
|
||||||
do {
|
do {
|
||||||
let results = try storeSearch.search(for: appName).wait()
|
let results = try storeSearch.search(for: searchTerm).wait()
|
||||||
if results.isEmpty {
|
if results.isEmpty {
|
||||||
throw MASError.noSearchResultsFound
|
throw MASError.noSearchResultsFound
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import PromiseKit
|
||||||
/// Protocol for searching the MAS catalog.
|
/// Protocol for searching the MAS catalog.
|
||||||
protocol StoreSearch {
|
protocol StoreSearch {
|
||||||
func lookup(appID: AppID) -> Promise<SearchResult?>
|
func lookup(appID: AppID) -> Promise<SearchResult?>
|
||||||
func search(for appName: String) -> Promise<[SearchResult]>
|
func search(for searchTerm: String) -> Promise<[SearchResult]>
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Entity: String {
|
enum Entity: String {
|
||||||
|
|
|
@ -13,8 +13,8 @@ import PromiseKit
|
||||||
class StoreSearchMock: StoreSearch {
|
class StoreSearchMock: StoreSearch {
|
||||||
var apps: [AppID: SearchResult] = [:]
|
var apps: [AppID: SearchResult] = [:]
|
||||||
|
|
||||||
func search(for appName: String) -> Promise<[SearchResult]> {
|
func search(for searchTerm: String) -> Promise<[SearchResult]> {
|
||||||
.value(apps.filter { $1.trackName.contains(appName) }.map { $1 })
|
.value(apps.filter { $1.trackName.contains(searchTerm) }.map { $1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
func lookup(appID: AppID) -> Promise<SearchResult?> {
|
func lookup(appID: AppID) -> Promise<SearchResult?> {
|
||||||
|
|
Loading…
Reference in a new issue