Documentation
¶
Overview ¶
Package readliner implement an io.Reader that reads from a tty with history and completions.
Index ¶
- Constants
- type ReadLiner
- func (r *ReadLiner) Close() error
- func (r *ReadLiner) IsTerminal() bool
- func (r *ReadLiner) Newline()
- func (r *ReadLiner) Read(b []byte) (int, error)
- func (r *ReadLiner) SetCompletions(completions []string, begin bool)
- func (r *ReadLiner) SetContPrompt(prompt string)
- func (r *ReadLiner) SetEol(eol string)
- func (r *ReadLiner) SetPrompt(prompt string)
Constants ¶
const DefaultEOL = "\r\n"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReadLiner ¶
type ReadLiner struct {
// contains filtered or unexported fields
}
ReadLiner is an io.Reader that can read from a tty using `readline`
func New ¶
New creates a new ReadLiner and sets the tty in raw mode.
`prompt` is printed before reading from each line. `history` should be the path to the history file.
func (*ReadLiner) Close ¶
Close closes the ReadLiner and reset the TTY. If there is an history file, the current history is written to the file.
func (*ReadLiner) IsTerminal ¶
IsTerminal returns true if ReadLiner is operating on a terminal that supports editing (i.e. not redirected from a file)
Note that when not in terminal mode, history is disabled.
func (*ReadLiner) Newline ¶
func (r *ReadLiner) Newline()
Newline indicate we are starting a new line (in multiline mode).
This reset the prompt to the "new line" prompt. The prompt switch to the "continuation" prompt after reading the current line.
func (*ReadLiner) SetCompletions ¶
SetCompletions sets a `completer` with a list of completions words.
If `begin` is true, words are completed only at the beginning of the line (i.e. command names). If false, the last word of the line is completed.
func (*ReadLiner) SetContPrompt ¶
SetContPrompt changes the continuation `prompt` for the ReadLiner
This is used to support multiline. See description of `Newline`.