forked from Versent/saml2aws
-
Notifications
You must be signed in to change notification settings - Fork 6
/
prompter.go
35 lines (28 loc) · 978 Bytes
/
prompter.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
34
35
package prompter
import prompt "github.com/segmentio/go-prompt"
// Prompter handles prompting user for input
type Prompter interface {
RequestSecurityCode(pattern string) string
Choice(prompt string, options []string) string
StringRequired(pr string) string
}
// CliPrompter used to prompt for cli input
type CliPrompter struct {
}
// NewCli builds a new cli prompter
func NewCli() Prompter {
return &CliPrompter{}
}
// RequestSecurityCode request a security code to be entered by the user
func (cli *CliPrompter) RequestSecurityCode(pattern string) string {
return prompt.StringRequired("\nSecurity Token [%s]\n", pattern)
}
// Choice given the choice return the option selected
func (cli *CliPrompter) Choice(pr string, options []string) string {
selected := prompt.Choose(pr, options)
return options[selected]
}
// StringRequired prompt for string which is required
func (cli *CliPrompter) StringRequired(pr string) string {
return prompt.StringRequired(pr)
}