Documentation ¶
Overview ¶
Package prompt provides the prompt interface and its implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
InitialColor is the initial color for a prompt prefix.
var ( ErrSkip = errors.New("skip") ErrAbort = errors.New("abort") )
var New = newPrompt
New instantiates a new Prompt implementation. New will be replaced when e2egen command is executed. Initially, Prompt doesn't have a prefix, so you have to call SetPrefix for displaying it.
Functions ¶
This section is empty.
Types ¶
type Color ¶
Color represents a valid color for a prompt prefix.
type Completer ¶
type Completer interface { // Complete receives d that is a piece of input, and returns some suggestions. // The prompt shows suggestions from it. Complete(d Document) []*Suggest }
Completer is a mechanism that provides REPL completion.
type Document ¶
Document is a piece of input that has several information such that text before the cursor, a work before the cursor, etc.
type Prompt ¶
type Prompt interface { // Input reads keyboard input. // If ctrl+d is entered, Input returns io.EOF. // If ctrl+c is entered, Input returns ErrAbort. Input() (string, error) Select(message string, options []string) (idx int, selected string, _ error) // SetPrefix changes the current prefix to the passed one. SetPrefix(prefix string) // SetPrefixColor changes the current color to the passed one. SetPrefixColor(color Color) // SetCompleter set a completer for prompt completion. SetCompleter(c Completer) // GetCommandHistory gets a command history. The order of history is asc. GetCommandHistory() []string }
type Suggest ¶
Suggest is a suggestion for the completion.
func FilterHasPrefix ¶
FilterHasPrefix filters s by whether have sub as the prefix. If ignoreCase is true, differences between upper and lower casing are ignored.
func NewSuggestion ¶
NewSuggestion returns a new *Suggest from text and description.