forked from manifoldco/promptui
/
promptui.go
29 lines (24 loc) · 1.24 KB
/
promptui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Package promptui is a library providing a simple interface to create command-line prompts for go.
// It can be easily integrated into spf13/cobra, urfave/cli or any cli go application.
//
// promptui has two main input modes:
//
// Prompt provides a single line for user input. It supports optional live validation,
// confirmation and masking the input.
//
// Select provides a list of options to choose from. It supports pagination, search,
// detailed view and custom templates.
package promptui
import "errors"
// ErrEOF is the error returned from prompts when EOF is encountered.
var ErrEOF = errors.New("^D")
// ErrInterrupt is the error returned from prompts when an interrupt (ctrl-c) is
// encountered.
var ErrInterrupt = errors.New("^C")
// ErrAbort is the error returned when confirm prompts are supplied "n"
var ErrAbort = errors.New("")
// ValidateFunc is a placeholder type for any validation functions that validates a given input. It should return
// a ValidationError if the input is not valid. If you have a potentially expensive validation function, you can
// use the completed parameter to only run expensive operations in the validation function when the user has finished
// typing.
type ValidateFunc func(val string, completed bool) error