mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 11:33:13 +00:00
⛔ Disable signin command on macOS 10.13 and greater
This commit is contained in:
parent
912fcb7925
commit
d156e737d8
2 changed files with 28 additions and 18 deletions
|
@ -13,13 +13,17 @@ struct SignInCommand: CommandProtocol {
|
|||
typealias Options = SignInOptions
|
||||
let verb = "signin"
|
||||
let function = "Sign in to the Mac App Store"
|
||||
|
||||
|
||||
func run(_ options: Options) -> Result<(), MASError> {
|
||||
|
||||
|
||||
if #available(macOS 10.13, *) {
|
||||
return .failure(.signInDisabled)
|
||||
}
|
||||
|
||||
guard ISStoreAccount.primaryAccount == nil else {
|
||||
return .failure(.alreadySignedIn)
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
printInfo("Signing in to Apple ID: \(options.username)")
|
||||
|
||||
|
@ -42,17 +46,17 @@ struct SignInCommand: CommandProtocol {
|
|||
struct SignInOptions: OptionsProtocol {
|
||||
let username: String
|
||||
let password: String
|
||||
|
||||
let dialog: Bool
|
||||
|
||||
|
||||
let dialog: Bool
|
||||
|
||||
typealias ClientError = MASError
|
||||
|
||||
|
||||
static func create(username: String) -> (_ password: String) -> (_ dialog: Bool) -> SignInOptions {
|
||||
return { password in { dialog in
|
||||
return SignInOptions(username: username, password: password, dialog: dialog)
|
||||
}}
|
||||
}
|
||||
|
||||
|
||||
static func evaluate(_ m: CommandMode) -> Result<SignInOptions, CommandantError<MASError>> {
|
||||
return create
|
||||
<*> m <| Argument(usage: "Apple ID")
|
||||
|
|
|
@ -10,32 +10,38 @@ import Foundation
|
|||
|
||||
enum MASError: Error, CustomStringConvertible {
|
||||
case notSignedIn
|
||||
case signInDisabled
|
||||
case signInFailed(error: NSError?)
|
||||
case alreadySignedIn
|
||||
|
||||
|
||||
case purchaseFailed(error: NSError?)
|
||||
case downloadFailed(error: NSError?)
|
||||
case noDownloads
|
||||
case cancelled
|
||||
|
||||
|
||||
case searchFailed
|
||||
case noSearchResultsFound
|
||||
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .notSignedIn:
|
||||
return "Not signed in"
|
||||
|
||||
|
||||
case .signInDisabled:
|
||||
return "The 'signin' command has been disabled on this macOS version. " +
|
||||
"\nFor more info see: " +
|
||||
"https://github.com/mas-cli/mas/issues/107"
|
||||
|
||||
case .signInFailed(let error):
|
||||
if let error = error {
|
||||
return "Sign in failed: \(error.localizedDescription)"
|
||||
} else {
|
||||
return "Sign in failed"
|
||||
}
|
||||
|
||||
|
||||
case .alreadySignedIn:
|
||||
return "Already signed in"
|
||||
|
||||
|
||||
case .purchaseFailed(let error):
|
||||
if let error = error {
|
||||
return "Download request failed: \(error.localizedDescription)"
|
||||
|
@ -49,16 +55,16 @@ enum MASError: Error, CustomStringConvertible {
|
|||
} else {
|
||||
return "Download failed"
|
||||
}
|
||||
|
||||
|
||||
case .noDownloads:
|
||||
return "No downloads began"
|
||||
|
||||
|
||||
case .cancelled:
|
||||
return "Download cancelled"
|
||||
|
||||
|
||||
case .searchFailed:
|
||||
return "Search failed"
|
||||
|
||||
|
||||
case .noSearchResultsFound:
|
||||
return "No results found"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue