mirror of https://gitlab.com/gitlab-org/cli.git
feat(pkg/prompt): add `Select()` to select a single option
This commit is contained in:
parent
2bc3a0ad3c
commit
250296d53b
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue