-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprompt.go
33 lines (27 loc) · 847 Bytes
/
prompt.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
package bump
import "github.com/AlecAivazis/survey/v2"
type prompter struct{}
func newPrompter() Prompter {
return &prompter{}
}
func (p *prompter) Input(question string, validator survey.Validator) (string, error) {
var result string
if err := survey.AskOne(&survey.Input{Message: question}, &result, survey.WithValidator(validator)); err != nil {
return "", err
}
return result, nil
}
func (p *prompter) Select(question string, options []string) (string, error) {
var result string
if err := survey.AskOne(&survey.Select{Message: question, Options: options}, &result); err != nil {
return "", err
}
return result, nil
}
func (p *prompter) Confirm(question string) (bool, error) {
var result bool
if err := survey.AskOne(&survey.Confirm{Message: question}, &result); err != nil {
return false, err
}
return result, nil
}