-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
runnersurvey.go
44 lines (38 loc) · 1.07 KB
/
runnersurvey.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// +build linux darwin windows openbsd netbsd freebsd
package main
import (
"fmt"
"github.com/AlecAivazis/survey/v2"
)
func RunnerGroupSurvey(taskAgentPool string, taskAgentPools []string) string {
prompt := &survey.Select{
Message: "Choose a runner group:",
Options: taskAgentPools,
}
err := survey.AskOne(prompt, &taskAgentPool)
if err != nil {
fmt.Println("Failed to retrieve your choice using default runner group: " + taskAgentPool)
}
return taskAgentPool
}
func GetInput(prompt string, answer string) string {
in := &survey.Input{
Message: prompt,
Default: answer,
}
if err := survey.AskOne(in, &answer); err != nil {
fmt.Println("Failed to retrieve your choice using default: " + answer)
}
return answer
}
func GetMultiSelectInput(prompt string, options []string) []string {
answer := []string{}
in := &survey.MultiSelect{
Message: prompt,
Options: options,
}
if err := survey.AskOne(in, &answer); err != nil {
fmt.Printf("Failed to retrieve your choice selecting all: %v\n", options)
}
return answer
}