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")