asker

package
v0.0.0-...-fe3d7fc Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asker

type Asker struct {
	IsVimMode bool
	Mask      rune
	Stdin     io.ReadCloser
	Stdout    io.WriteCloser
}

Asker is a helper for retrieving user input from the given reader

func DefaultAsker

func DefaultAsker() *Asker

DefaultAsker creates a asker using STDOUT and STDIN

func (*Asker) Ask

func (a *Asker) Ask(question string, validations ...Validation) (string, error)

Ask retrieves user input from the current Reader

func (*Asker) AskConfirm

func (a *Asker) AskConfirm(question string) (bool, error)

AskConfirm retrieves confirmation and attempts to parse the various way that a use might supply confirmation e.g. yes, YES, y, si, yup etc.

func (*Asker) AskSecret

func (a *Asker) AskSecret(question string, confirm bool, validations ...Validation) (string, error)

AskSecret asks for user input without echoing input back to terminal. Note that this method is only supported through stdin

func (*Asker) AskSelect

func (a *Asker) AskSelect(question string, items []string) (int, error)

AskSelect prompts the user from a list of items and returns the index of the selected item

type Validation

type Validation func(string) error

Validation defines a general validation processor for a given string

Jump to

Keyboard shortcuts

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