Documentation ¶
Index ¶
- func Required(answer string) error
- func ValidateFormat(validator func(string) bool) func(string) error
- type UserDialog
- func (ud *UserDialog) Query(prompt string, validator *re.Regexp, key string) (groups []string)
- func (ud *UserDialog) QueryAll(prompt string, validator *re.Regexp, key string, maxMatches int) (matches [][]string)
- func (ud *UserDialog) QueryBool(prompt string, key string) (value bool)
- func (ud *UserDialog) QueryInt(prompt string, key string, bitSize int) (value int64)
- func (ud *UserDialog) QueryString(prompt string, validator func(string) error, key string) string
- func (ud *UserDialog) QueryStringPattern(prompt string, validator *re.Regexp, key string) (answer string)
- func (ud *UserDialog) Write(message string, v ...interface{})
- func (ud *UserDialog) Writeln(format string, v ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type UserDialog ¶
type UserDialog struct {
// contains filtered or unexported fields
}
UserDialog is an abstraction for question/answer based user interaction
func NewUserDialog ¶
NewUserDialog initializes a UserDialog with safe defaults
func (*UserDialog) Query ¶
Query writes the prompt to the user and returns the regex groups if it matches the validator pattern
func (*UserDialog) QueryAll ¶
func (ud *UserDialog) QueryAll(prompt string, validator *re.Regexp, key string, maxMatches int) (matches [][]string)
QueryAll is a version of Query that can return multiple matches
func (*UserDialog) QueryBool ¶
func (ud *UserDialog) QueryBool(prompt string, key string) (value bool)
QueryBool writes the prompt to the user and returns the answer if it can be parsed as a boolean
func (*UserDialog) QueryInt ¶
func (ud *UserDialog) QueryInt(prompt string, key string, bitSize int) (value int64)
QueryInt writes the prompt to the user and returns the answer if it can be parsed as an integer
func (*UserDialog) QueryString ¶
QueryString writes the prompt to the user and returns the answer if it passes the validator function
func (*UserDialog) QueryStringPattern ¶
func (ud *UserDialog) QueryStringPattern(prompt string, validator *re.Regexp, key string) (answer string)
QueryStringPattern is a version of QueryString taking a regular expression pattern as the validator
func (*UserDialog) Write ¶
func (ud *UserDialog) Write(message string, v ...interface{})
Write message to user
func (*UserDialog) Writeln ¶
func (ud *UserDialog) Writeln(format string, v ...interface{})
Writeln writes a message to the user that completes a line