Documentation
¶
Index ¶
- Variables
- func Start(f func(ctx context.Context, p *Prompter) error, opts ...Option) error
- type ConfirmStyles
- type InputOption
- func WithInputCharLimit(limit int) InputOption
- func WithInputPlaceholder(placeholder string) InputOption
- func WithInputPrompt(prompt string) InputOption
- func WithInputSuggestions(suggestions []string) InputOption
- func WithInputValidate(validate func(string) error) InputOption
- func WithInputWidth(width int) InputOption
- type InputStyles
- type Keybind
- type KeybindEvent
- type KeybindHandle
- type KeybindOption
- type MessageBoxHandle
- type Option
- type Prompter
- func (p *Prompter) AwaitConfirm(prompt string) (bool, error)
- func (p *Prompter) AwaitInput(opts ...InputOption) (string, error)
- func (p *Prompter) AwaitSelect(prompt string, options []string) (string, error)
- func (p *Prompter) AwaitSelectDefault(prompt string, options []string, defaultValue string) (string, error)
- func (p *Prompter) Clear()
- func (p *Prompter) Confirm(prompt string) (promise.Promise[bool], error)
- func (p *Prompter) Input(opts ...InputOption) (promise.Promise[string], error)
- func (p *Prompter) Keybinds(bindings []Keybind, opts ...KeybindOption) (*KeybindHandle, error)
- func (p *Prompter) Log(msg string)
- func (p *Prompter) Logf(format string, args ...any)
- func (p *Prompter) MessageBox(opts ...InputOption) (*MessageBoxHandle, error)
- func (p *Prompter) Select(prompt string, options []string) (promise.Promise[string], error)
- func (p *Prompter) SelectDefault(prompt string, options []string, defaultValue string) (promise.Promise[string], error)
- func (p *Prompter) Status(message string) (*StatusHandle, error)
- func (p *Prompter) StatusKeybinds(message string, bindings []Keybind, opts ...KeybindOption) (*StatusKeybindHandle, error)
- type SelectStyles
- type StatusHandle
- func (h *StatusHandle) Clear() error
- func (h *StatusHandle) Error(message string) error
- func (h *StatusHandle) Idle(message string) error
- func (h *StatusHandle) Message(message string) error
- func (h *StatusHandle) Progress(message string, percent float64) error
- func (h *StatusHandle) SetProgress(percent float64) error
- func (h *StatusHandle) Success(message string) error
- func (h *StatusHandle) Working(message string) error
- type StatusKeybindHandle
- func (h *StatusKeybindHandle) Clear() error
- func (h *StatusKeybindHandle) Error(message string) error
- func (h *StatusKeybindHandle) Events() <-chan KeybindEvent
- func (h *StatusKeybindHandle) Idle(message string) error
- func (h *StatusKeybindHandle) Message(message string) error
- func (h *StatusKeybindHandle) Progress(message string, percent float64) error
- func (h *StatusKeybindHandle) Set(bindings []Keybind) error
- func (h *StatusKeybindHandle) SetProgress(percent float64) error
- func (h *StatusKeybindHandle) Success(message string) error
- func (h *StatusKeybindHandle) Working(message string) error
- type StatusStyles
- type Styles
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoninteractive = errors.New("prompter requires an interactive terminal")
ErrNoninteractive indicates that prompter could not acquire an interactive terminal.
Functions ¶
Types ¶
type ConfirmStyles ¶
type InputOption ¶
type InputOption func(*inputOptions)
func WithInputCharLimit ¶
func WithInputCharLimit(limit int) InputOption
func WithInputPlaceholder ¶
func WithInputPlaceholder(placeholder string) InputOption
func WithInputPrompt ¶
func WithInputPrompt(prompt string) InputOption
func WithInputSuggestions ¶
func WithInputSuggestions(suggestions []string) InputOption
func WithInputValidate ¶
func WithInputValidate(validate func(string) error) InputOption
func WithInputWidth ¶
func WithInputWidth(width int) InputOption
type InputStyles ¶
type KeybindEvent ¶
type KeybindHandle ¶
type KeybindHandle struct {
// contains filtered or unexported fields
}
func (*KeybindHandle) Clear ¶
func (h *KeybindHandle) Clear() error
func (*KeybindHandle) Events ¶
func (h *KeybindHandle) Events() <-chan KeybindEvent
func (*KeybindHandle) Set ¶
func (h *KeybindHandle) Set(bindings []Keybind) error
type KeybindOption ¶
type KeybindOption func(*keybindOptions)
func WithKeybindPrompt ¶
func WithKeybindPrompt(prompt string) KeybindOption
func WithKeybindSeparator ¶
func WithKeybindSeparator(separator string) KeybindOption
type MessageBoxHandle ¶
type MessageBoxHandle struct {
// contains filtered or unexported fields
}
func (*MessageBoxHandle) Clear ¶
func (h *MessageBoxHandle) Clear() error
func (*MessageBoxHandle) Messages ¶
func (h *MessageBoxHandle) Messages() <-chan string
type Option ¶
type Option func(*options)
func WithContext ¶
func WithMaxHistoryLen ¶
func WithStyles ¶
type Prompter ¶
type Prompter struct {
// contains filtered or unexported fields
}
func (*Prompter) AwaitInput ¶
func (p *Prompter) AwaitInput(opts ...InputOption) (string, error)
func (*Prompter) AwaitSelect ¶
func (*Prompter) AwaitSelectDefault ¶
func (*Prompter) Keybinds ¶
func (p *Prompter) Keybinds(bindings []Keybind, opts ...KeybindOption) (*KeybindHandle, error)
func (*Prompter) MessageBox ¶
func (p *Prompter) MessageBox(opts ...InputOption) (*MessageBoxHandle, error)
func (*Prompter) SelectDefault ¶
func (*Prompter) StatusKeybinds ¶
func (p *Prompter) StatusKeybinds(message string, bindings []Keybind, opts ...KeybindOption) (*StatusKeybindHandle, error)
type SelectStyles ¶
type StatusHandle ¶
type StatusHandle struct {
// contains filtered or unexported fields
}
func (*StatusHandle) Clear ¶
func (h *StatusHandle) Clear() error
func (*StatusHandle) Error ¶
func (h *StatusHandle) Error(message string) error
func (*StatusHandle) Idle ¶
func (h *StatusHandle) Idle(message string) error
func (*StatusHandle) Message ¶
func (h *StatusHandle) Message(message string) error
func (*StatusHandle) Progress ¶
func (h *StatusHandle) Progress(message string, percent float64) error
func (*StatusHandle) SetProgress ¶
func (h *StatusHandle) SetProgress(percent float64) error
func (*StatusHandle) Success ¶
func (h *StatusHandle) Success(message string) error
func (*StatusHandle) Working ¶
func (h *StatusHandle) Working(message string) error
type StatusKeybindHandle ¶
type StatusKeybindHandle struct {
// contains filtered or unexported fields
}
func (*StatusKeybindHandle) Clear ¶
func (h *StatusKeybindHandle) Clear() error
func (*StatusKeybindHandle) Error ¶
func (h *StatusKeybindHandle) Error(message string) error
func (*StatusKeybindHandle) Events ¶
func (h *StatusKeybindHandle) Events() <-chan KeybindEvent
func (*StatusKeybindHandle) Idle ¶
func (h *StatusKeybindHandle) Idle(message string) error
func (*StatusKeybindHandle) Message ¶
func (h *StatusKeybindHandle) Message(message string) error
func (*StatusKeybindHandle) Progress ¶
func (h *StatusKeybindHandle) Progress(message string, percent float64) error
func (*StatusKeybindHandle) Set ¶
func (h *StatusKeybindHandle) Set(bindings []Keybind) error
func (*StatusKeybindHandle) SetProgress ¶
func (h *StatusKeybindHandle) SetProgress(percent float64) error
func (*StatusKeybindHandle) Success ¶
func (h *StatusKeybindHandle) Success(message string) error
func (*StatusKeybindHandle) Working ¶
func (h *StatusKeybindHandle) Working(message string) error
type StatusStyles ¶
type Styles ¶
type Styles struct {
Confirm ConfirmStyles
Input InputStyles
Select SelectStyles
Status StatusStyles
}
func DefaultStyles ¶
func DefaultStyles() *Styles
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
credit-card
command
|
|
|
keybinds
command
|
|
|
message-box
command
|
|
|
noninteractive
command
|
|
|
status
command
|
|
|
status-keybinds
command
|
|
Click to show internal directories.
Click to hide internal directories.