mas/Sources/MasKit/Commands/SignOut.swift

33 lines
895 B
Swift
Raw Normal View History

2016-02-14 01:33:17 +00:00
//
// SignOut.swift
// mas-cli
//
// Created by Andrew Naylor on 14/02/2016.
// Copyright © 2016 Andrew Naylor. All rights reserved.
//
2018-07-04 14:56:10 -06:00
import Commandant
2018-10-14 13:41:19 -06:00
import CommerceKit
2018-07-04 14:56:10 -06:00
public struct SignOutCommand: CommandProtocol {
public typealias Options = NoOptions<MASError>
public let verb = "signout"
public let function = "Sign out of the Mac App Store"
public init() {}
2019-01-11 18:06:02 -07:00
2019-01-11 18:28:03 -07:00
/// Runs the command.
2021-03-21 22:46:17 -07:00
public func run(_: Options) -> Result<Void, MASError> {
if #available(macOS 10.13, *) {
let accountService: ISAccountService = ISServiceProxy.genericShared().accountService
accountService.signOut()
2019-01-11 18:06:02 -07:00
} else {
// Using CKAccountStore to sign out does nothing on High Sierra
// https://github.com/mas-cli/mas/issues/129
CKAccountStore.shared().signOut()
}
2016-09-17 13:58:38 +01:00
return .success(())
2016-02-14 01:33:17 +00:00
}
2016-09-17 13:58:38 +01:00
}