feat(pkg/prompt): add `Select()` to select a single option

This commit is contained in:
Leo 2021-01-02 02:23:52 -03:00
parent 2bc3a0ad3c
commit 250296d53b
1 changed files with 17 additions and 0 deletions

View File

@ -60,6 +60,23 @@ func AskMultiline(response interface{}, name, question string, defaultVal string
return nil
}
func Select(response interface{}, name string, question string, options []string, opts ...survey.AskOpt) error {
prompt := []*survey.Question{
{
Name: name,
Prompt: &survey.Select{
Message: question,
Options: options,
},
},
}
err := Ask(prompt, response, opts...)
if err != nil {
return err
}
return nil
}
var AskOne = survey.AskOne
var Ask = survey.Ask