ui

package
v1.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func (p *Printer) Cmd(msg string)

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

func (p *Printer) Done(msg string)

Done prints the final success message for a command, bold green in colour mode.

func (*Printer) Fail

func (p *Printer) Fail(msg string, err error) error

Fail prints a failure indicator for msg, reports the error, and returns ErrAlreadyReported. Use in return statements: return p.Fail("stage", err)

func (*Printer) Header

func (p *Printer) Header(cmd string)

Header prints a command banner at the start of a kubesoloctl command.

func (*Printer) Hint

func (p *Printer) Hint(label string, lines ...string)

Hint prints a labelled tip block with indented shell-snippet lines.

func (*Printer) Info

func (p *Printer) Info(msg string)

Info prints a plain indented line — use for next-steps, tips, or shell snippets shown at the end of a command.

func (*Printer) Label

func (p *Printer) Label(label, value string)

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

func (p *Printer) OK(msg, detail string)

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.

func (*Printer) Section

func (p *Printer) Section(title string)

Section prints a labelled group header — use for "Next steps" blocks.

func (*Printer) Step

func (p *Printer) Step(msg string)

Step announces a stage that is about to run. Call it before a potentially slow operation so the user has immediate visual feedback.

func (*Printer) Warn

func (p *Printer) Warn(msg string)

Warn prints a non-fatal warning.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL