ask

package
v6.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskPassword

func AskPassword(question string) string

AskPassword asks the user to enter a password.

func AskPasswordOnce

func AskPasswordOnce(question string) string

AskPasswordOnce asks the user to enter a password.

It's the same as AskPassword, but it won't ask to enter it again.

Types

type Asker

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

Asker holds a reader for reading input into CLI questions.

func NewAsker

func NewAsker(reader *bufio.Reader) Asker

NewAsker returns a new Asker that utilizes the supplied reader.

func (*Asker) AskBool

func (a *Asker) AskBool(question string, defaultAnswer string) (bool, error)

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

func (*Asker) AskChoice

func (a *Asker) AskChoice(question string, choices []string, defaultAnswer string) (string, error)

AskChoice asks the user to select one of multiple options.

func (*Asker) AskInt

func (a *Asker) AskInt(question string, min int64, max int64, defaultAnswer string, validate func(int64) error) (int64, error)

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

func (*Asker) AskString

func (a *Asker) AskString(question string, defaultAnswer string, validate func(string) error) (string, error)

AskString 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