ask

package
v0.0.0-...-5d27ecb Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxRetriesInput = errors.New("invalid number input tried")

ErrMaxRetriesInput represents when an input is invalid after numerous attempts

Functions

This section is empty.

Types

type Ask

type Ask struct {
	// contains filtered or unexported fields
}

Ask represents a way of asking questions and getting answers from the output and input terminal retrospectively.

func New

func New(input io.Reader, output io.Writer) *Ask

New creates a new Ask with sane defaults.

func (*Ask) Bool

func (a *Ask) Bool(question, defaultAnswer string) (bool, error)

Bool asks a question and expect a yes/no answer.

func (*Ask) Choice

func (a *Ask) Choice(question string, choices []string, defaultAnswer string) (string, error)

Choice asks the user to select one of multiple options

func (*Ask) Int

func (a *Ask) Int(question string, min, max int64, defaultAnswer string) (int64, error)

Int asks the user to enter an integer between a min and max value

func (*Ask) Password

func (a *Ask) Password(question string) (string, error)

Password asks the user to enter a password.

func (*Ask) PasswordOnce

func (a *Ask) PasswordOnce(question string) string

PasswordOnce asks the user to enter a password.

func (*Ask) String

func (a *Ask) String(question, defaultAnswer string, validate func(string) error) (string, error)

String asks the user to enter a string, which optionally conforms to a validation function.

func (*Ask) Text

func (a *Ask) Text(question string) (string, error)

Text asks the user to enter a string, which optionally conforms to a validation function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL