prompt

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEmail

func ValidateEmail(email string) error

Types

type Prompt

type Prompt struct {
	// InfoLines that are printed before the.
	InfoLines []string
	// The label of the prompt.
	Label string
	// The color of the label
	LabelColour color.Attribute
	// HideEntered will mask the input is true.
	HideEntered bool
	// The validation function for the input
	Validator ValidateFunc
	// Invalid represent the string to show if the input is invalid.
	Invalid string
	// The number of maximum allowed retries. If set to zero it will be automatically
	// assigned 999.
	Retries int
}

Prompt represents a single line input field with options for validation and input masks.

func GetConfirmationPrompt

func GetConfirmationPrompt(s string, i []string) *Prompt

GetConfirmationPrompt returns a Prompt that has been configured to show a y/n prompt to the user with `s` as label and `i` as info lines.

func (*Prompt) Run

func (p *Prompt) Run() (string, error)

Run executes the prompt. Its prints the informational lines first and then shows the user the prompt. The execution will stay alive until the max retries has been reached. It returns the value and an error if any occurred during the prompt's execution.

type ValidateFunc

type ValidateFunc func(string) error

ValidateFunc is for any validation functions that validates a given input. It should return an err if the input is not valid.

Jump to

Keyboard shortcuts

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