mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
Improve unwrapping.
Cleanup code. Partial #592 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
87aaba555d
commit
2edd21803b
4 changed files with 13 additions and 8 deletions
|
@ -47,7 +47,7 @@ extension ISStoreAccount: StoreAccount {
|
||||||
|
|
||||||
let password =
|
let password =
|
||||||
password.isEmpty && !systemDialog
|
password.isEmpty && !systemDialog
|
||||||
? String(validatingUTF8: getpass("Password: "))!
|
? String(validatingUTF8: getpass("Password: ")) ?? ""
|
||||||
: password
|
: password
|
||||||
|
|
||||||
guard !password.isEmpty || systemDialog else {
|
guard !password.isEmpty || systemDialog else {
|
||||||
|
|
|
@ -44,15 +44,18 @@ extension Mas {
|
||||||
}
|
}
|
||||||
url.scheme = masScheme
|
url.scheme = masScheme
|
||||||
|
|
||||||
|
guard let urlString = url.string else {
|
||||||
|
printError("Unable to construct URL")
|
||||||
|
throw MASError.searchFailed
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
try openCommand.run(arguments: url.string!)
|
try openCommand.run(arguments: urlString)
|
||||||
} catch {
|
} catch {
|
||||||
printError("Unable to launch open command")
|
printError("Unable to launch open command")
|
||||||
throw MASError.searchFailed
|
throw MASError.searchFailed
|
||||||
}
|
}
|
||||||
if openCommand.failed {
|
if openCommand.failed {
|
||||||
let reason = openCommand.process.terminationReason
|
printError("Open failed: (\(openCommand.process.terminationReason)) \(openCommand.stderr)")
|
||||||
printError("Open failed: (\(reason)) \(openCommand.stderr)")
|
|
||||||
throw MASError.searchFailed
|
throw MASError.searchFailed
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -61,7 +61,7 @@ extension Mas {
|
||||||
|
|
||||||
if kill.terminationStatus != 0, debug {
|
if kill.terminationStatus != 0, debug {
|
||||||
let output = stderr.fileHandleForReading.readDataToEndOfFile()
|
let output = stderr.fileHandleForReading.readDataToEndOfFile()
|
||||||
printError("killall failed:\n\(String(data: output, encoding: String.Encoding.utf8)!)")
|
printError("killall failed:\n\(String(data: output, encoding: .utf8) ?? "Error info not available")")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wipe Download Directory
|
// Wipe Download Directory
|
||||||
|
|
|
@ -78,16 +78,18 @@ extension StoreSearch {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
components.queryItems = [
|
var queryItems = [
|
||||||
URLQueryItem(name: "media", value: "software"),
|
URLQueryItem(name: "media", value: "software"),
|
||||||
URLQueryItem(name: "entity", value: entity.rawValue),
|
URLQueryItem(name: "entity", value: entity.rawValue),
|
||||||
]
|
]
|
||||||
|
|
||||||
if let country {
|
if let country {
|
||||||
components.queryItems!.append(URLQueryItem(name: "country", value: country))
|
queryItems.append(URLQueryItem(name: "country", value: country))
|
||||||
}
|
}
|
||||||
|
|
||||||
components.queryItems!.append(URLQueryItem(name: action.queryItemName, value: queryItemValue))
|
queryItems.append(URLQueryItem(name: action.queryItemName, value: queryItemValue))
|
||||||
|
|
||||||
|
components.queryItems = queryItems
|
||||||
|
|
||||||
return components.url
|
return components.url
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue