Disable signin command on macOS 10.13 and greater

This commit is contained in:
Ben Chatelain 2018-08-10 20:31:03 -06:00
parent 912fcb7925
commit d156e737d8
2 changed files with 28 additions and 18 deletions

View file

@ -16,6 +16,10 @@ struct SignInCommand: CommandProtocol {
func run(_ options: Options) -> Result<(), MASError> {
if #available(macOS 10.13, *) {
return .failure(.signInDisabled)
}
guard ISStoreAccount.primaryAccount == nil else {
return .failure(.alreadySignedIn)
}

View file

@ -10,6 +10,7 @@ import Foundation
enum MASError: Error, CustomStringConvertible {
case notSignedIn
case signInDisabled
case signInFailed(error: NSError?)
case alreadySignedIn
@ -26,6 +27,11 @@ enum MASError: Error, CustomStringConvertible {
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)"