Documentation
¶
Index ¶
- func Checklist(idst interface{}, label string, ioptions interface{}) error
- func Clip(x, a, b int) int
- func Default(idst, ideflt interface{}) defaultValue
- func DefaultProgressStyle(b []byte, f float64)
- func DefaultWithCaret(idst, ideflt interface{}, pos int) defaultValue
- func Enter(label string)
- func MakeRawTerminal(hide bool) (func() error, error)
- func Max(a, b int) int
- func Min(a, b int) int
- func NonZeroDefault(idst, ideflt interface{}) defaultValue
- func Prompt(idst interface{}, label string, validators ...Validator) error
- func Select(idst interface{}, label string, ioptions interface{}) error
- func TerminalSize() (int, int, error)
- func YesNo(label string, deflt bool) bool
- type DownloadProgress
- type Form
- type MultiDownloadProgress
- type MultiDownloadProgressItem
- type Number
- type PercentProgress
- type Progress
- type ProgressStyle
- type Validator
- func AbsolutePath() Validator
- func After(after any) Validator
- func And(validators ...Validator) Validator
- func Before(before any) Validator
- func DateRange(min, max time.Time) Validator
- func Dir() Validator
- func DomainName() Validator
- func EmailAddress() Validator
- func FQDN() Validator
- func File() Validator
- func IPAddress() Validator
- func IPv4Address() Validator
- func IPv6Address() Validator
- func In(list any) Validator
- func Is(elem any) Validator
- func Not(validator Validator) Validator
- func NotIn(list any) Validator
- func NumRange(min, max float64) Validator
- func Or(validators ...Validator) Validator
- func Path() Validator
- func Pattern(pattern, message string) Validator
- func Port() Validator
- func Prefix(afix string) Validator
- func StrLength(min, max int) Validator
- func Suffix(afix string) Validator
- func TelephoneNumber() Validator
- func TopDomainName() Validator
- func UserName() Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default(idst, ideflt interface{}) defaultValue
Default is the default value used for Prompt.
func DefaultProgressStyle ¶
func DefaultWithCaret ¶
func DefaultWithCaret(idst, ideflt interface{}, pos int) defaultValue
Default is the default value with the initial text caret position used for Prompt. A position of -1 means at the end of the value.
func MakeRawTerminal ¶
func NonZeroDefault ¶
func NonZeroDefault(idst, ideflt interface{}) defaultValue
NonZeroDefault is the default value used for Prompt. The default value will be empty when the destination is its zero value.
func Prompt ¶
Prompt is a regular text prompt that can read into a (string,[]byte,bool,int,int8,int16,int32,int64,uint,uint8,uint16,uint32,uint64,float32,float64,time.Time) or a type that implements the Scanner interface. The idst must be a pointer to a variable, its value determines the default/initial value. The initial value will be editable in-place. To set the text caret initial position when idst is editable, use prompt.Default(value, position). When editing, you can use the Left or Ctrl+B, Right or Ctrl+F, Home or Ctrl+A, End or Ctrl+E to move around; Backspace and Delete to delete a character; Ctrl+U and Ctrl+K to delete from the caret to the beginning and the end of the line respectively; Ctrl+C and Escape to quit; and Ctrl+Z and Enter to confirm the input. All validators must be satisfies, otherwise an error is printed and the answer should be corrected.
func Select ¶
Select is a list selection prompt that allows to select one of the list of possible values. The ioptions must be a slice of options. The idst must be a pointer to a variable and must of the same type as the options (set the option value) or an integer (set the option index). The value od idst determines the initial selected value. Users can select an option using Up, Ctrl+P, 'k', or Shift+Tab to move up, Down, Ctrl+N, 'j', or Tab to move down. Both wraps around. Ctrl+C or Escape to quit, and Ctrl+Z, Enter, or Ctrl+D to select an option.
func TerminalSize ¶
Types ¶
type DownloadProgress ¶
type DownloadProgress struct {
Progress
// contains filtered or unexported fields
}
func NewDownloadProgress ¶
func NewDownloadProgress(prefix string, resp *http.Response, style ProgressStyle) *DownloadProgress
func (*DownloadProgress) Add ¶
func (p *DownloadProgress) Add(value int64)
func (*DownloadProgress) Close ¶
func (p *DownloadProgress) Close() error
func (*DownloadProgress) Set ¶
func (p *DownloadProgress) Set(value int64)
type MultiDownloadProgress ¶
type MultiDownloadProgress struct {
// contains filtered or unexported fields
}
func NewMultiDownloadProgress ¶
func NewMultiDownloadProgress(style ProgressStyle) *MultiDownloadProgress
func (*MultiDownloadProgress) Add ¶
func (p *MultiDownloadProgress) Add(prefix string, resp *http.Response) io.ReadCloser
func (*MultiDownloadProgress) Stop ¶
func (p *MultiDownloadProgress) Stop()
type MultiDownloadProgressItem ¶
type MultiDownloadProgressItem struct {
// contains filtered or unexported fields
}
func (*MultiDownloadProgressItem) Close ¶
func (p *MultiDownloadProgressItem) Close() error
type PercentProgress ¶
func NewPercentProgress ¶
func NewPercentProgress[T Number](prefix string, maximum T, style ProgressStyle) *PercentProgress[T]
func (*PercentProgress[T]) Add ¶
func (p *PercentProgress[T]) Add(value T)
func (*PercentProgress[T]) Set ¶
func (p *PercentProgress[T]) Set(value T)
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
func NewProgress ¶
func NewProgress(prefix, suffix string, style ProgressStyle) *Progress
type ProgressStyle ¶
type Validator ¶
Validator is a validator interface.
func And ¶
And evaluates multiple validators using the logical AND operator, i.e. must satisfy all validators. This is only useful inside logical OR validators.
func DateRange ¶
DateRange matches if the input is in the given time range (inclusive). Use time.Time's zero value for an open limit.
func Not ¶
Not evaluates the validator using the logical NOT operator, i.e. satisfies if the validator does not satisfy.
func NumRange ¶
NumRange matches if the input is in the given number range (inclusive). Use NaN or +/-Inf for an open limit.
func Or ¶
Or evaluates multiple validators using the logical OR operator, i.e. at least one validator must be satisfied.
func StrLength ¶
StrLength matches if the input length is in the given range (inclusive). Use -1 for an open limit.
func TelephoneNumber ¶
func TelephoneNumber() Validator
TelephoneNumber matches a valid telephone number.