generator

package
Version: v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

Types

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
y or Y : Canonical URL