Help us shape the future of Go! Take the 2026 Go Developer Survey

theme

package
v1.65.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// Primary brand color
	Primary = lipgloss.AdaptiveColor{Light: "#4169e1", Dark: "#6e8dfc"}
	// Secondary accent color
	Secondary = lipgloss.AdaptiveColor{Light: "#86ab69", Dark: "#93c770"}
	// General Background
	Background = lipgloss.AdaptiveColor{Light: "#f5f5f5", Dark: "#171717"}
	// General Foreground text
	Foreground = lipgloss.AdaptiveColor{Light: "#0f1729", Dark: "#ffffff"}
	// Muted background/borders
	Muted = lipgloss.AdaptiveColor{Light: "#ebebeb", Dark: "#0f0f0f"}
	// Muted foreground text (e.g. descriptions, secondary info)
	MutedForeground = lipgloss.AdaptiveColor{Light: "#65758b", Dark: "#b3b3b3"}
	// Destructive/Error color
	Destructive = lipgloss.AdaptiveColor{Light: "#dc2626", Dark: "#f87171"}
	// Warning color for non-fatal issues.
	Warning = lipgloss.AdaptiveColor{Light: "#d97706", Dark: "#f59e0b"}
	// Debug color for verbose/diagnostic output.
	Debug = lipgloss.AdaptiveColor{Light: "#c084fc", Dark: "#e879f9"}
	// Success color alias (Secondary doubles as success).
	Success = Secondary
)

Color tokens based on gv-tech design system.

View Source
var (
	Out io.Writer = os.Stdout
	Err io.Writer = os.Stderr
)

Out and Err are the writers used for styled banner messages. Out is for success/info/warning banners (normal output), Err is for error banners. Tests may replace them via SetWriters. log.SetWriters propagates to these to keep output unified.

View Source
var (
	// BaseText is the default text style
	BaseText = lipgloss.NewStyle().Foreground(Foreground)

	// MutedText is used for secondary information
	MutedText = lipgloss.NewStyle().Foreground(MutedForeground)

	// BoldText highlights text in the default foreground
	BoldText = BaseText.Bold(true)

	// PrimaryText is text colored in the primary brand color
	PrimaryText = lipgloss.NewStyle().Foreground(Primary)

	// SuccessText is text colored in the secondary/success color
	SuccessText = lipgloss.NewStyle().Foreground(Secondary)

	// ErrorText is text colored in the destructive color
	ErrorText = lipgloss.NewStyle().Foreground(Destructive).Bold(true)

	// InfoBox is a generic callout box with a primary border
	InfoBox = lipgloss.NewStyle().
			Border(lipgloss.RoundedBorder()).
			BorderForeground(Primary).
			Padding(0, 1).
			MarginBottom(1)

	// SuccessBanner is a highlighted block for success messages
	SuccessBanner = lipgloss.NewStyle().
					Background(Secondary).
					Foreground(Background).
					Bold(true).
					Padding(0, 1).
					MarginRight(1)

	// WarningBanner is a highlighted block for warnings
	WarningBanner = lipgloss.NewStyle().
					Background(Warning).
					Foreground(Background).
					Bold(true).
					Padding(0, 1).
					MarginRight(1)

	// InfoBanner is a highlighted block for informational messages.
	InfoBanner = lipgloss.NewStyle().
				Background(Primary).
				Foreground(Background).
				Bold(true).
				Padding(0, 1).
				MarginRight(1)

	// ErrorBanner is a highlighted block for critical errors
	ErrorBanner = lipgloss.NewStyle().
				Background(Destructive).
				Foreground(Background).
				Bold(true).
				Padding(0, 1).
				MarginRight(1)

	// DiffAddLine highlights an added diff line with a green background.
	DiffAddLine = lipgloss.NewStyle().
				Background(Secondary).
				Foreground(Background)

	// DiffDelLine highlights a removed diff line with a red background.
	DiffDelLine = lipgloss.NewStyle().
				Background(Destructive).
				Foreground(Background)

	// DiffAddText colors added diffstat markers green.
	DiffAddText = lipgloss.NewStyle().Foreground(Secondary).Bold(true)

	// DiffDelText colors removed diffstat markers red.
	DiffDelText = lipgloss.NewStyle().Foreground(Destructive).Bold(true)

	// DiffHunk highlights unified-diff hunk headers.
	DiffHunk = lipgloss.NewStyle().Foreground(MutedForeground).Bold(true)

	// DiffHeader highlights diff metadata lines (diff --git, index, ---, +++).
	DiffHeader = lipgloss.NewStyle().Foreground(Primary).Bold(true)
)
View Source
var ErrorBoxStyle = lipgloss.NewStyle().
	Border(lipgloss.RoundedBorder()).
	BorderForeground(Destructive).
	Padding(1, 2).
	MarginTop(1).
	MarginBottom(1)

ErrorBoxStyle defines the container style for the rich error box.

Functions

func Configure added in v1.59.0

func Configure(noColorFlag bool)

Configure sets global color behavior. When noColor is true, or the NO_COLOR environment variable is set, lipgloss falls back to ASCII output.

func EngTheme

func EngTheme() *huh.Theme

EngTheme returns a custom theme for huh forms based on the eng CLI brand colors. It uses the gv-tech token palette for light and dark modes.

func ErrorMessage

func ErrorMessage(msg string)

ErrorMessage prints a formatted error message.

func HandleError added in v1.16.0

func HandleError(err error)

HandleError takes an error, styles it into a rich CLI box and prints it to the configured Err writer. If the error implements ActionableError, it appends the suggestion. Callers are responsible for exiting (e.g. os.Exit(1)) after calling this.

func InfoMessage

func InfoMessage(msg string)

InfoMessage prints a formatted informational message.

func NewActionableError added in v1.16.0

func NewActionableError(err error, suggestion string) error

NewActionableError wraps an existing error with a helpful suggestion.

Example
err := NewActionableError(errors.New("auth failed"), "run: eng gitlab auth set")
var actErr ActionableError
if errors.As(err, &actErr) {
	fmt.Println(actErr.Error())
	fmt.Println(actErr.Suggestion())
}
Output:
auth failed
run: eng gitlab auth set

func NoColorEnabled added in v1.59.0

func NoColorEnabled() bool

NoColorEnabled reports whether color output is currently disabled.

func SetFileLog added in v1.52.0

func SetFileLog(w io.Writer)

SetFileLog tees plain copies of banner messages to w (nil disables). The caller owns w: it is never closed here.

func SetWriters added in v1.51.0

func SetWriters(out, errOut io.Writer)

SetWriters replaces Out/Err in a thread-safe way.

func SuccessMessage

func SuccessMessage(msg string)

SuccessMessage prints a formatted success message.

func WarningMessage

func WarningMessage(msg string)

WarningMessage prints a formatted warning message.

Types

type ActionableError added in v1.16.0

type ActionableError interface {
	error
	Suggestion() string
}

ActionableError is an interface that extends the standard error interface with a Suggestion() method. Implement this to provide helpful tips for resolving errors.

Jump to

Keyboard shortcuts

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