-
Notifications
You must be signed in to change notification settings - Fork 1
/
survey.go
24 lines (18 loc) · 915 Bytes
/
survey.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
//go:generate mockgen -package survey -destination survey_mock.go -source survey.go
package survey
import "github.com/AlecAivazis/survey/v2"
// Asker defines the interface for asking survey questions.
type Asker interface {
Ask(questions []*survey.Question, answers any, opts ...survey.AskOpt) error
AskOne(p survey.Prompt, response any, opts ...survey.AskOpt) error
}
// RealAsker is an implementation of SurveyAsker that uses the actual survey library.
type RealAsker struct{}
// Ask asks survey questions using the actual survey library.
func (r *RealAsker) Ask(questions []*survey.Question, answers any, opts ...survey.AskOpt) error {
return survey.Ask(questions, answers, opts...)
}
// AskOne asks a single survey question using the actual survey library.
func (r *RealAsker) AskOne(prompt survey.Prompt, response any, opts ...survey.AskOpt) error {
return survey.AskOne(prompt, response, opts...)
}