Documentation
¶
Overview ¶
Package ui provides shared formatting primitives for Veil's CLI output.
Index ¶
- Variables
- func Debugf(w io.Writer, format string, args ...any)
- func Dim(w io.Writer, msg string)
- func Dimf(w io.Writer, format string, args ...any)
- func Errorf(w io.Writer, format string, args ...any)
- func Footer(w io.Writer, msg string)
- func FormatError(w io.Writer, msg string, hint string, cause ...error) error
- func FormatWarning(w io.Writer, msg string, hint string)
- func Header(w io.Writer, label string)
- func Phase(w io.Writer, msg string)
- func RedactPath(s string) string
- func RelativeTime(t time.Time) string
- func SetColor(mode string)
- func Step(w io.Writer, msg string)
- func TableHeader(tw *tabwriter.Writer, cols ...string)
- func Warn(w io.Writer, msg string)
- func Warnf(w io.Writer, format string, args ...any)
Constants ¶
This section is empty.
Variables ¶
var ( Success = color.New(color.FgGreen) Warning = color.New(color.FgYellow) Err = color.New(color.FgRed, color.Bold) Muted = color.New(color.FgHiBlack) Bold = color.New(color.Bold) )
Color palette — use these for inline styling beyond the helper functions.
Functions ¶
func Debugf ¶
Debugf prints a muted debug line with Printf-style formatting. The output is identical to Dimf today; the separate verb documents intent ("this is diagnostic") and leaves room for future gating behind a --verbose flag.
func Dim ¶
Dim prints a single muted line followed by a newline. It replaces the common `fmt.Fprintln(w, ui.Muted.Sprint(msg))` pattern seen across the runner and signals packages.
func Errorf ¶
Errorf prints a styled "error: <msg>\n" line to w with Printf-style formatting. Use this for non-cobra-return error output (e.g. internal package warnings that historically used log.Printf). For cobra RunE returns that also render an error line, use FormatError, which returns a sentinel error suitable for Cobra's error chain.
func FormatError ¶
FormatError prints a red "error: msg" line with an optional dimmed hint to w. Returns a sentinel error for use as a cobra RunE return value. When a cause is supplied, the returned error wraps it via %w so callers can errors.Is against the original. Only the first cause is honored; additional arguments are ignored so callers cannot accidentally over-specify.
func FormatWarning ¶
FormatWarning prints a yellow "warning: msg" line with an optional dimmed hint to w.
func RedactPath ¶
RedactPath replaces $HOME prefixes inside s with "~" so user-facing error messages don't leak the user's home-directory layout. Non-home paths pass through unchanged. An empty or unresolvable $HOME disables redaction.
func RelativeTime ¶
RelativeTime formats a time relative to now:
<60s → "just now" <60m → "Xm ago" <24h → "Xh ago" <7d → "Xd ago" >=7d → "2026-04-01" (date only)
func SetColor ¶
func SetColor(mode string)
SetColor configures the global color mode. Called once from root PersistentPreRunE. mode is "auto", "always", or "never".
func TableHeader ¶
TableHeader prints dimmed, tab-separated column headers to a tabwriter.
Types ¶
This section is empty.