github.com/versent/saml2aws@v2.17.0+incompatible/pkg/prompter/prompter.go (about) 1 package prompter 2 3 var defaultPrompter Prompter = NewCli() 4 5 // Prompter handles prompting user for input 6 type Prompter interface { 7 RequestSecurityCode(string) string 8 ChooseWithDefault(string, string, []string) (string, error) 9 Choose(string, []string) int 10 StringRequired(string) string 11 String(string, string) string 12 Password(string) string 13 } 14 15 // SetPrompter configure an aternate prompter to the default one 16 func SetPrompter(prmpt Prompter) { 17 defaultPrompter = prmpt 18 } 19 20 // RequestSecurityCode request a security code to be entered by the user 21 func RequestSecurityCode(pattern string) string { 22 return defaultPrompter.RequestSecurityCode(pattern) 23 } 24 25 // ChooseWithDefault given the choice return the option selected with a default 26 func ChooseWithDefault(pr string, defaultValue string, options []string) (string, error) { 27 return defaultPrompter.ChooseWithDefault(pr, defaultValue, options) 28 } 29 30 // Choose given the choice return the option selected 31 func Choose(pr string, options []string) int { 32 return defaultPrompter.Choose(pr, options) 33 } 34 35 // StringRequired prompt for string which is required 36 func StringRequired(pr string) string { 37 return defaultPrompter.StringRequired(pr) 38 } 39 40 // String prompt for string which is required 41 func String(pr string, defaultValue string) string { 42 return defaultPrompter.String(pr, defaultValue) 43 } 44 45 // Password prompt for password which is required 46 func Password(pr string) string { 47 return defaultPrompter.Password(pr) 48 }