Documentation
¶
Overview ¶
Package ui handles terminal input and output: prompting for variables, confirming dangerous steps, and printing progress.
Index ¶
- func IsTruthy(s string) bool
- type Auto
- type Field
- type Printer
- func (p *Printer) Bold(s string) string
- func (p *Printer) Detail(format string, args ...any)
- func (p *Printer) Dim(s string) string
- func (p *Printer) Info(format string, args ...any)
- func (p *Printer) Step(format string, args ...any)
- func (p *Printer) Success(format string, args ...any)
- func (p *Printer) Warn(format string, args ...any)
- type Prompter
- type Terminal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Auto ¶
type Auto struct {
// Assume is the answer given to every Confirm.
Assume bool
}
Auto answers from defaults without prompting, for CI and --yes runs.
type Field ¶
type Field struct {
Label string
Help string
Default string
Options []string // non-empty means a choice
Bool bool
Validate func(string) error
}
Field describes one question. It is deliberately not the blueprint's Variable type — the prompter should not need to know what a blueprint is.
type Printer ¶
type Printer struct {
// Quiet suppresses everything except warnings and errors.
Quiet bool
// contains filtered or unexported fields
}
Printer writes progress output. It is separate from Prompter so that a non-interactive run can still produce readable logs.
func NewPrinter ¶
NewPrinter builds a printer over a stream.
type Prompter ¶
type Prompter interface {
Ask(f Field) (string, error)
Confirm(prompt string, def bool) (bool, error)
}
Prompter collects answers. Two implementations exist: a terminal prompter, and one that answers from defaults for non-interactive runs.
Whether a human is present is deliberately not part of this interface. That is a fact about the process, not about how questions get asked, and the two were conflated in an earlier version — which made piped answers silently resolve to defaults.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal prompts on a real terminal.
func NewTerminal ¶
NewTerminal builds a prompter over the given streams.