diff --git a/Sources/mas/AppStore/ISStoreAccount.swift b/Sources/mas/AppStore/ISStoreAccount.swift index 1c8afa0..f0d27ec 100644 --- a/Sources/mas/AppStore/ISStoreAccount.swift +++ b/Sources/mas/AppStore/ISStoreAccount.swift @@ -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 { diff --git a/Sources/mas/Commands/Open.swift b/Sources/mas/Commands/Open.swift index 4ae4247..82e98de 100644 --- a/Sources/mas/Commands/Open.swift +++ b/Sources/mas/Commands/Open.swift @@ -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 { diff --git a/Sources/mas/Commands/Reset.swift b/Sources/mas/Commands/Reset.swift index 6698780..76a32bd 100644 --- a/Sources/mas/Commands/Reset.swift +++ b/Sources/mas/Commands/Reset.swift @@ -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 diff --git a/Sources/mas/Controllers/StoreSearch.swift b/Sources/mas/Controllers/StoreSearch.swift index 12a46e0..166e7fd 100644 --- a/Sources/mas/Controllers/StoreSearch.swift +++ b/Sources/mas/Controllers/StoreSearch.swift @@ -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 }