Version: v0.5.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 8 Imported by: 0




This section is empty.


This section is empty.


func Required

func Required(answer string) error

Required is a validator that checks whether the input contains any characters

func ValidateFormat

func ValidateFormat(validator func(string) bool) func(string) error

ValidateFormat is a validation wrapper turning false bool results into errors


type UserDialog

type UserDialog struct {
	// contains filtered or unexported fields

UserDialog is an abstraction for question/answer based user interaction

func NewUserDialog

func NewUserDialog(reader io.Reader, writer io.Writer, props map[string]string) *UserDialog

NewUserDialog initializes a UserDialog with safe defaults

func (*UserDialog) Query

func (ud *UserDialog) Query(prompt string, validator *re.Regexp, key string) (groups []string)

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

func (ud *UserDialog) QueryString(prompt string, validator func(string) error, key string) string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL