mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33:28 +02:00
44 lines
677 B
Go
44 lines
677 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/AlecAivazis/survey"
|
|
)
|
|
|
|
// the questions to ask
|
|
var simpleQs = []*survey.Question{
|
|
{
|
|
Name: "name",
|
|
Prompt: &survey.Input{
|
|
Message: "What is your name?",
|
|
},
|
|
Validate: survey.Required,
|
|
},
|
|
{
|
|
Name: "color",
|
|
Prompt: &survey.Select{
|
|
Message: "Choose a color:",
|
|
Options: []string{"red", "blue", "green"},
|
|
},
|
|
Validate: survey.Required,
|
|
},
|
|
}
|
|
|
|
func main() {
|
|
answers := struct {
|
|
Name string
|
|
Color string
|
|
}{}
|
|
|
|
// ask the question
|
|
err := survey.Ask(simpleQs, &answers)
|
|
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
return
|
|
}
|
|
// print the answers
|
|
fmt.Printf("%s chose %s.\n", answers.Name, answers.Color)
|
|
}
|