Documentation
¶
Overview ¶
Package ui provides lightweight terminal output primitives for kubesoloctl. It respects NO_COLOR and TERM=dumb and degrades to plain ASCII in non-TTY environments (CI pipelines, serial consoles, piped output).
Index ¶
- Variables
- func ColorEnabled() bool
- type Printer
- func (p *Printer) Blank()
- func (p *Printer) Cmd(msg string)
- func (p *Printer) Done(msg string)
- func (p *Printer) Fail(msg string, err error) error
- func (p *Printer) Header(cmd string)
- func (p *Printer) Hint(label string, lines ...string)
- func (p *Printer) Info(msg string)
- func (p *Printer) Label(label, value string)
- func (p *Printer) OK(msg, detail string)
- func (p *Printer) Section(title string)
- func (p *Printer) Step(msg string)
- func (p *Printer) Warn(msg string)
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyReported = fmt.Errorf("")
ErrAlreadyReported is returned by Fail so callers can propagate a non-nil error to cobra (causing exit 1) without cobra reprinting the message. main.go checks err.Error() == "" to distinguish it from real errors.
Functions ¶
func ColorEnabled ¶
func ColorEnabled() bool
ColorEnabled reports whether ANSI colour output is appropriate for the current stderr. Exported so configureLogging can share the same detection.
Types ¶
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer writes structured, human-readable output to stderr. In a colour-capable TTY it uses ANSI sequences and Unicode symbols; in non-TTY or NO_COLOR environments it falls back to plain ASCII. All symbols and the message column are aligned at a consistent indent so that zerolog detail lines (indented 5 spaces via the custom ConsoleWriter in configureLogging) nest cleanly under each Printer step.
func New ¶
func New() *Printer
New returns a Printer targeting os.Stderr with auto-detected colour support.
func (*Printer) Blank ¶
func (p *Printer) Blank()
Blank emits a bare newline — use to separate visual groups in footers.
func (*Printer) Cmd ¶
Cmd prints a primary shell command at a shallow indent, highlighted in colour mode. Use for the first actionable commands to run after a successful install.
func (*Printer) Done ¶
Done prints the final success message for a command, bold green in colour mode.
func (*Printer) Fail ¶
Fail prints a failure indicator for msg, reports the error, and returns ErrAlreadyReported. Use in return statements: return p.Fail("stage", err)
func (*Printer) Info ¶
Info prints a plain indented line — use for next-steps, tips, or shell snippets shown at the end of a command.
func (*Printer) Label ¶
Label prints a right-padded label and value pair on a single line, with the label dimmed in colour mode. Use for compact command-reference tables such as "Manage systemctl status kubesolo".
func (*Printer) OK ¶
OK marks a completed stage. detail is optional trailing context (path, version, …); pass "" to omit. Text is aligned so the message starts at the same column as zerolog detail lines.