mirror of
https://github.com/mas-cli/mas
synced 2024-11-25 04:50:24 +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 =
|
||||
password.isEmpty && !systemDialog
|
||||
? String(validatingUTF8: getpass("Password: "))!
|
||||
? String(validatingUTF8: getpass("Password: ")) ?? ""
|
||||
: password
|
||||
|
||||
guard !password.isEmpty || systemDialog else {
|
||||
|
|
|
@ -44,15 +44,18 @@ extension Mas {
|
|||
}
|
||||
url.scheme = masScheme
|
||||
|
||||
guard let urlString = url.string else {
|
||||
printError("Unable to construct URL")
|
||||
throw MASError.searchFailed
|
||||
}
|
||||
do {
|
||||
try openCommand.run(arguments: url.string!)
|
||||
try openCommand.run(arguments: urlString)
|
||||
} catch {
|
||||
printError("Unable to launch open command")
|
||||
throw MASError.searchFailed
|
||||
}
|
||||
if openCommand.failed {
|
||||
let reason = openCommand.process.terminationReason
|
||||
printError("Open failed: (\(reason)) \(openCommand.stderr)")
|
||||
printError("Open failed: (\(openCommand.process.terminationReason)) \(openCommand.stderr)")
|
||||
throw MASError.searchFailed
|
||||
}
|
||||
} catch {
|
||||
|
|
|
@ -61,7 +61,7 @@ extension Mas {
|
|||
|
||||
if kill.terminationStatus != 0, debug {
|
||||
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
|
||||
|
|
|
@ -78,16 +78,18 @@ extension StoreSearch {
|
|||
return nil
|
||||
}
|
||||
|
||||
components.queryItems = [
|
||||
var queryItems = [
|
||||
URLQueryItem(name: "media", value: "software"),
|
||||
URLQueryItem(name: "entity", value: entity.rawValue),
|
||||
]
|
||||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue