Documentation ¶
Overview ¶
Package promptui provides ui elements for the command line prompt.
Index ¶
Constants ¶
const SelectedAdd = -1
SelectedAdd is returned from SelectWithAdd when add is selected.
Variables ¶
var ErrAbort = errors.New("")
ErrAbort is returned when confirm prompts are supplied "n"
var ErrEOF = errors.New("^D")
ErrEOF is returned from prompts when EOF is encountered.
var ErrInterrupt = errors.New("^C")
ErrInterrupt is returned from prompts when an interrupt (ctrl-c) is encountered.
Functions ¶
func FailedValue ¶
FailedValue returns a value as if it were entered via prompt, invalid
func SuccessfulValue ¶
SuccessfulValue returns a value as if it were entered via prompt, valid
Types ¶
type Prompt ¶
type Prompt struct { Label string // Label is the value displayed on the command line prompt Default string // Default is the initial value to populate in the prompt // Validate is optional. If set, this function is used to validate the input // after each character entry. Validate ValidateFunc // If mask is set, this value is displayed instead of the actual input // characters. Mask rune IsConfirm bool IsVimMode bool Preamble *string // contains filtered or unexported fields }
Prompt represents a single line text field input.
type Select ¶
type Select struct { Label string // Label is the value displayed on the command line prompt. Items []string // Items are the items to use in the list. IsVimMode bool // Whether readline is using Vim mode. }
Select represents a list for selecting a single item
type SelectWithAdd ¶
type SelectWithAdd struct { Label string // Label is the value displayed on the command line prompt. Items []string // Items are the items to use in the list. AddLabel string // The label used in the item list for creating a new item. // Validate is optional. If set, this function is used to validate the input // after each character entry. Validate ValidateFunc IsVimMode bool // Whether readline is using Vim mode. }
SelectWithAdd represents a list for selecting a single item, or selecting a newly created item.
type ValidateFunc ¶
ValidateFunc validates the given input. It should return a ValidationError if the input is not valid.
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError is the class of errors resulting from invalid inputs, returned from a ValidateFunc.
func NewValidationError ¶
func NewValidationError(msg string) *ValidationError
NewValidationError creates a new validation error with the given message.
func (*ValidationError) Error ¶
func (v *ValidationError) Error() string
Error implements the error interface for ValidationError.