ui

package
v0.0.0-...-83bc8a5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package ui provides shared CLI reporting primitives for rich and plain-text terminal output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorEnabled

func ColorEnabled(w io.Writer, mode ColorMode) bool

ColorEnabled reports whether styling should be emitted for the writer.

Types

type ColorMode

type ColorMode string

ColorMode controls whether terminal styling should be emitted.

const (
	// ColorAuto enables ANSI styling only when the target writer is a terminal.
	ColorAuto ColorMode = "auto"
	// ColorAlways forces ANSI styling even for non-terminal writers.
	ColorAlways ColorMode = "always"
	// ColorNever disables ANSI styling entirely.
	ColorNever ColorMode = "never"
)

func ParseColorMode

func ParseColorMode(value string) (ColorMode, error)

ParseColorMode validates a user-supplied color mode.

type Console

type Console struct {
	// contains filtered or unexported fields
}

Console renders consistent human-facing CLI output.

func NewConsole

func NewConsole(out io.Writer, mode ColorMode) *Console

NewConsole creates a console that respects the requested color mode.

func (*Console) Accent

func (c *Console) Accent(text string) string

Accent renders informational highlight text.

func (*Console) Brand

func (c *Console) Brand(text string) string

Brand renders branded product text.

func (*Console) Code

func (c *Console) Code(text string) string

Code renders command or identifier text with emphasis.

func (*Console) Error

func (c *Console) Error(label string, details string) error

Error prints an error line.

func (*Console) Header

func (c *Console) Header(title string, details ...string) string

Header renders the branded CLI header block.

func (*Console) Info

func (c *Console) Info(label string, details string) error

Info prints a low-severity informational line.

func (*Console) Join

func (c *Console) Join(parts ...string) string

Join combines metadata fragments with a shared separator.

func (*Console) Muted

func (c *Console) Muted(text string) string

Muted renders low-emphasis metadata text.

func (*Console) Path

func (c *Console) Path(text string) string

Path renders a filesystem path consistently across CLI output.

func (*Console) Printf

func (c *Console) Printf(format string, args ...any) error

Printf writes formatted text to the configured output writer.

func (*Console) Println

func (c *Console) Println(text string) error

Println writes a full line to the configured output writer.

func (*Console) Stage

func (c *Console) Stage(label string, details string) error

Stage prints an informational stage line.

func (*Console) Strong

func (c *Console) Strong(text string) string

Strong renders high-emphasis text.

func (*Console) Success

func (c *Console) Success(label string, details string) error

Success prints a success line.

func (*Console) Warning

func (c *Console) Warning(label string, details string) error

Warning prints a warning line.

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

Reporter renders consistent CLI output for commands.

func NewReporter

func NewReporter(out, errOut io.Writer, mode ...ColorMode) *Reporter

NewReporter creates a reporter that auto-detects whether rich styling should be enabled.

func (*Reporter) Diagnostics

func (r *Reporter) Diagnostics(diagnostics []validator.Diagnostic) error

Diagnostics prints grouped warnings and errors.

func (*Reporter) Stage

func (r *Reporter) Stage(label string, details string) error

Stage prints a step header.

func (*Reporter) Success

func (r *Reporter) Success(label string, details string) error

Success prints a success line.

func (*Reporter) Summary

func (r *Reporter) Summary(ok bool, errors int, warnings int, blocks int, nodes int, edges int) error

Summary prints the final result line.

Jump to

Keyboard shortcuts

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