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 20:56:10 +00:00
|
|
|
import Commandant
|
2018-10-14 19:41:19 +00:00
|
|
|
import CommerceKit
|
2019-01-30 06:15:24 +00:00
|
|
|
import Result
|
2018-07-04 20:56:10 +00:00
|
|
|
|
2018-10-14 21:35:48 +00: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-12 01:06:02 +00:00
|
|
|
|
2019-01-12 01:28:03 +00:00
|
|
|
/// Runs the command.
|
2019-01-30 06:15:24 +00:00
|
|
|
public func run(_: Options) -> Result<(), MASError> {
|
2018-04-14 20:06:36 +00:00
|
|
|
if #available(macOS 10.13, *) {
|
|
|
|
let accountService: ISAccountService = ISServiceProxy.genericShared().accountService
|
|
|
|
accountService.signOut()
|
2019-01-12 01:06:02 +00:00
|
|
|
} else {
|
2018-04-14 20:06:36 +00:00
|
|
|
// Using CKAccountStore to sign out does nothing on High Sierra
|
|
|
|
// https://github.com/mas-cli/mas/issues/129
|
|
|
|
CKAccountStore.shared().signOut()
|
|
|
|
}
|
|
|
|
|
2016-09-17 12:58:38 +00:00
|
|
|
return .success(())
|
2016-02-14 01:33:17 +00:00
|
|
|
}
|
2016-09-17 12:58:38 +00:00
|
|
|
}
|