Documentation
¶
Overview ¶
Package term provides line editing, history, and tab completion for the interactive shell.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTerminal ¶
IsTerminal reports whether w is a real terminal (as opposed to a pipe or file). This is a convenience wrapper for callers that need to decide whether to run an interactive loop.
Types ¶
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal wraps liner.State to provide line editing, history, and completion.
func New ¶
New returns a Terminal.
If historyFile is non-empty the history is loaded from it at construction and saved back on Close. A missing history file is silently ignored.
func (*Terminal) ReadLine ¶
ReadLine prints prompt and reads one line of input.
Returns ("", io.EOF) at end of input. Ctrl-C (ErrPromptAborted) returns ("", nil) so the caller can show a new prompt rather than exit.
func (*Terminal) SetCompleter ¶
SetCompleter installs a tab-completion function.
fn receives the full current line prefix and returns a slice of completion candidates (also full lines, not just the suffix).