Documentation
¶
Index ¶
- Variables
- func Choose(q string, opts []string, def string) string
- func Clear()
- func ClearChars(n int)
- func ClearLine(n int)
- func Confirm(q, def string) bool
- func IsPiped() bool
- func LoadMaxWidth()
- func NoColor(b *bool)
- func ReadPipedInput(args *[]string)
- func ReplaceLine(n int, s string)
- func WaitForEnter()
- type Options
- type PromptSuggester
- type Term
- func (t *Term) CancelInterruptHandler()
- func (t *Term) Choose(q string, opts []string, def string) string
- func (t *Term) ChooseTags(p string, items map[string]int) string
- func (t *Term) Clear()
- func (t *Term) ClearChars(n int)
- func (t *Term) ClearLine(n int)
- func (t *Term) Confirm(q, def string) bool
- func (t *Term) Input(p string) string
- func (t *Term) IsPiped() bool
- func (t *Term) PipedInput(input *[]string)
- func (t *Term) Prompt(p string) string
- func (t *Term) PromptWithFuzzySuggestions(p string, items []string) string
- func (t *Term) PromptWithSuggestions(p string, items []string) string
- func (t *Term) ReplaceLine(n int, s string)
- func (t *Term) SetInterruptFn(fn func(error))
- func (t *Term) SetReader(r io.Reader)
- type TermOptFn
Constants ¶
This section is empty.
Variables ¶
Default terminal settings.
var ( ErrNotTTY = errors.New("not a terminal") ErrGetTermSize = errors.New("getting terminal size") ErrTermWidthTooSmall = errors.New("terminal width too small") ErrTermHeightTooSmall = errors.New("terminal height too small") ErrUnsupportedPlatform = errors.New("unsupported platform") ErrNoStateToRestore = errors.New("no term state to restore") ErrNotInteractive = errors.New("not an interactive terminal") )
var ErrActionAborted = errors.New("action aborted")
Functions ¶
func ClearChars ¶ added in v0.1.1
func ClearChars(n int)
ClearChars deletes n characters in the console.
func LoadMaxWidth ¶
func LoadMaxWidth()
LoadMaxWidth updates `MaxWidth` to the current width if it is smaller than the existing `MaxWidth`.
func NoColor ¶
func NoColor(b *bool)
NoColor disables color output if the NO_COLOR environment variable is set.
func ReadPipedInput ¶
func ReadPipedInput(args *[]string)
ReadPipedInput reads the input from a pipe.
func WaitForEnter ¶
func WaitForEnter()
WaitForEnter displays a prompt and waits for the user to press ENTER.
Types ¶
type Options ¶ added in v0.1.5
type Options struct { PromptStr string InterruptFn func(error) // contains filtered or unexported fields }
Options represents the options for the terminal.
type PromptSuggester ¶
PromptSuggester is a function that generates suggestions for a given prompt.
type Term ¶ added in v0.1.5
type Term struct { Options // contains filtered or unexported fields }
Term is a struct that represents a terminal.
func (*Term) CancelInterruptHandler ¶ added in v0.1.5
func (t *Term) CancelInterruptHandler()
CancelInterruptHandler cancels the interrupt handler.
func (*Term) ChooseTags ¶ added in v0.1.5
ChooseTags prompts the user for input with suggestions based on the provided tags.
func (*Term) ClearChars ¶ added in v0.1.5
ClearChars deletes n characters in the console.
func (*Term) PipedInput ¶ added in v0.1.7
func (*Term) PromptWithFuzzySuggestions ¶ added in v0.1.5
PromptWithFuzzySuggestions prompts the user for input with fuzzy suggestions.
func (*Term) PromptWithSuggestions ¶ added in v0.1.5
PromptWithSuggestions prompts the user for input with suggestions based on the provided items.
func (*Term) ReplaceLine ¶ added in v0.1.5
ReplaceLine deletes n lines in the console and prints the given string.
func (*Term) SetInterruptFn ¶ added in v0.1.5
SetInterruptFn sets the interrupt function for the terminal.
type TermOptFn ¶ added in v0.1.5
type TermOptFn func(*Options)
TermOptFn is an option function for the terminal.
func WithInterruptFn ¶ added in v0.1.5
WithInterruptFn sets the interrupt function for the terminal.
func WithReader ¶ added in v0.1.5
WithReader sets the reader for the terminal.