From c5d8da360a1f1ca28c37352277a629a9f274c6ba Mon Sep 17 00:00:00 2001 From: David Date: Mon, 4 Dec 2023 09:41:22 +0700 Subject: [PATCH] [#498] Create Enum for gifhub runner type --- .../iOSTemplateMaker/SetUpCICDService.swift | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpCICDService.swift b/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpCICDService.swift index 3f830069..84e4544d 100644 --- a/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpCICDService.swift +++ b/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpCICDService.swift @@ -21,6 +21,22 @@ struct SetUpCICDService { } } } + + enum GithubRunnerType { + + case macOSLatest, selfHosted + + init?(_ name: String) { + switch name.lowercased() { + case "m", "macOS": + self = .macOSLatest + case "s", "self-hosted": + self = .selfHosted + default: + return nil + } + } + } private let fileManager = FileManager.default @@ -33,14 +49,10 @@ struct SetUpCICDService { switch service { case .github: - var runnerType: String? + var runnerType: GithubRunnerType? while runnerType == nil { print("Which workflow runner do you want to use? [(m)acos-latest/(s)elf-hosted]: ") - runnerType = readLine()?.lowercased() - if runnerType != "m" && runnerType != "s" { - print("Invalid input. Please enter 'm' for macOS-latest or 's' for self-hosted.") - runnerType = nil - } + runnerType = GithubRunnerType(readLine().string) } print("Setting template for Github Actions") fileManager.removeItems(in: "bitrise.yml")