Sha256: f29f6f1796702a6fb5883c28f612df4877a7d7550e512faf43794651896da6c5

Contents?: true

Size: 1.99 KB

Versions: 10

Compression:

Stored size: 1.99 KB

Contents

//
//  ClientShutdownCommand.swift
//  FastlaneRunner
//
//  Created by Joshua Liebowitz on 1/3/18.
//  Copyright © 2018 Joshua Liebowitz. All rights reserved.
//

import Foundation

struct ControlCommand: RubyCommandable {
    static let commandKey = "command"
    var type: CommandType { return .control }

    enum ShutdownCommandType {
        static let userMessageKey: String = "userMessage"

        enum CancelReason {
            static let reasonKey: String = "reason"
            case clientError
            case serverError

            var reasonText: String {
                switch self {
                case .clientError:
                    return "clientError"
                case .serverError:
                    return "serverError"
                }
            }
        }

        case done
        case cancel(cancelReason: CancelReason)

        var token: String {
            switch self {
            case .done:
                return "done"
            case .cancel:
                return "cancelFastlaneRun"
            }
        }
    }

    let message: String?
    let shutdownCommandType: ShutdownCommandType
    var commandJson: String {
        var jsonDictionary: [String: Any] = [ControlCommand.commandKey : self.shutdownCommandType.token]

        if let message = message {
            jsonDictionary[ShutdownCommandType.userMessageKey] = message
        }
        if case .cancel(let reason) = shutdownCommandType {
            jsonDictionary[ShutdownCommandType.CancelReason.reasonKey] = reason.reasonText
        }

        let jsonData = try! JSONSerialization.data(withJSONObject: jsonDictionary, options: [])
        let jsonString = String(data: jsonData, encoding: .utf8)!
        return jsonString
    }

    init(commandType: ShutdownCommandType, message: String? = nil) {
        self.shutdownCommandType = commandType
        self.message = message
    }
}

// Please don't remove the lines below
// They are used to detect outdated files
// FastlaneRunnerAPIVersion [0.9.2]

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fastlane-2.76.0.beta.20180111010004 fastlane/swift/ControlCommand.swift
fastlane-2.76.0.beta.20180110010004 fastlane/swift/ControlCommand.swift
fastlane-2.75.1 fastlane/swift/ControlCommand.swift
fastlane-2.75.0 fastlane/swift/ControlCommand.swift
fastlane-2.75.0.beta.20180109010003 fastlane/swift/ControlCommand.swift
fastlane-2.74.1 fastlane/swift/ControlCommand.swift
fastlane-2.74.0 fastlane/swift/ControlCommand.swift
fastlane-2.74.0.beta.20180108010004 fastlane/swift/ControlCommand.swift
fastlane-2.74.0.beta.20180107010004 fastlane/swift/ControlCommand.swift
fastlane-2.74.0.beta.20180106010004 fastlane/swift/ControlCommand.swift