Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
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: "#ef4444", Dark: "#7f1d1d"} )
Color tokens based on gv-tech design system.
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(lipgloss.AdaptiveColor{Light: "#f59e0b", Dark: "#d97706"}). 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) )
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 EngTheme ¶
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 HandleError ¶ added in v1.16.0
func HandleError(err error)
HandleError takes an error, styles it into a rich CLI box, prints it to stderr, and exits. If the error implements ActionableError, it appends the suggestion.
func InfoMessage ¶
func InfoMessage(msg string)
InfoMessage prints a formatted informational message.
func NewActionableError ¶ added in v1.16.0
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 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
ActionableError is an interface that extends the standard error interface with a Suggestion() method. Implement this to provide helpful tips for resolving errors.