Documentation
¶
Overview ¶
Package ui is the terminal prompter.
Index ¶
- func IsTerminal(f *os.File) bool
- type Prompter
- func (p *Prompter) Ask(question string) (string, error)
- func (p *Prompter) Confirm(question string, def bool) (bool, error)
- func (p *Prompter) Interactive() bool
- func (p *Prompter) MultiSelect(title string, options []ports.Option) ([]int, error)
- func (p *Prompter) OnTerminal() bool
- func (p *Prompter) Secret(question string) (string, error)
- func (p *Prompter) Select(title string, options []ports.Option) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTerminal ¶ added in v1.36.0
IsTerminal reports whether f is a terminal a person types on. Being a character device is not enough: the null device is one, and a command whose input is /dev/null has nobody to ask.
Types ¶
type Prompter ¶
type Prompter struct {
// Lang translates the questions and labels; nil is English.
Lang *core.Language
// contains filtered or unexported fields
}
Prompter asks questions on a reader/writer pair.
func New ¶
New builds a prompter. It is interactive only when stdin is a terminal and prompting was not disabled.
func (*Prompter) Ask ¶ added in v1.7.0
Ask reads one line of free text. An empty line is an empty answer.
func (*Prompter) Interactive ¶
Interactive reports whether the human can be asked.
func (*Prompter) MultiSelect ¶
MultiSelect asks for zero or more options as a comma-separated list.
func (*Prompter) OnTerminal ¶ added in v1.36.0
OnTerminal reports whether the person types on a real terminal, the one a child process can be attached to.