ui

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Theme = struct {
	// Title is used for prominent headings and section titles.
	// Bold purple (#7D56F4) to draw attention.
	Title lipgloss.Style

	// Success is used for positive feedback and completion messages.
	// Green (#04B575) to indicate successful operations.
	Success lipgloss.Style

	// Error is used for error messages and failure notifications.
	// Red (#FF4672) to alert users to problems.
	Error lipgloss.Style

	// Warning is used for warnings and cautionary messages.
	// Orange (#FFA657) to indicate non-critical issues requiring attention.
	Warning lipgloss.Style

	// Muted is used for secondary or less important information.
	// Gray (#626262) to de-emphasize supplementary text.
	Muted lipgloss.Style
}{
	Title:   lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#7D56F4")),
	Success: lipgloss.NewStyle().Foreground(lipgloss.Color("#04B575")),
	Error:   lipgloss.NewStyle().Foreground(lipgloss.Color("#FF4672")),
	Warning: lipgloss.NewStyle().Foreground(lipgloss.Color("#FFA657")),
	Muted:   lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")),
}

Theme provides consistent Lip Gloss styles for console and TUI output modes.

The theme defines 5 core styles for common CLI output patterns:

  • Title: Bold purple for prominent headings and titles
  • Success: Green for positive feedback and completion messages
  • Error: Red for error messages and failures
  • Warning: Orange for warnings and cautionary messages
  • Muted: Gray for secondary or subtle text

Lip Gloss automatically respects the NO_COLOR and CLICOLOR environment variables for accessibility. When NO_COLOR is set, all styles will render without ANSI color codes while preserving text formatting like bold.

Color Palette:

  • Title: #7D56F4 (Purple) - Bold, attention-grabbing
  • Success: #04B575 (Green) - Positive, affirmative
  • Error: #FF4672 (Red) - Alerts, problems
  • Warning: #FFA657 (Orange) - Caution, non-critical issues
  • Muted: #626262 (Gray) - Subdued, secondary information

Example usage:

// Render a success message
fmt.Println(Theme.Success.Render("✓ Project created successfully"))

// Render an error with additional context
fmt.Fprintln(os.Stderr, Theme.Error.Render("Error:"), "file not found")

// Combine styles in output
fmt.Printf("%s\n%s\n",
    Theme.Title.Render("Configuration"),
    Theme.Muted.Render("Using default settings"))

The Theme is used by Renderer implementations to provide consistent visual styling across all output modes.

Functions

This section is empty.

Types

type UIConfig

type UIConfig struct {
	// Mode specifies the output mode.
	Mode UIMode

	// NoColor disables color output (respects NO_COLOR env var).
	NoColor bool

	// JSON enables JSON output mode for scripting and automation.
	// Takes highest precedence in mode detection.
	JSON bool

	// Interactive forces interactive TUI mode even in non-TTY environments.
	// Takes precedence over auto-detection but lower than JSON.
	Interactive bool

	// LogLevel controls developer debug logging (debug, info, warn, error, off).
	// Defaults to "off" to hide debugging from end users.
	LogLevel string
}

UIConfig holds configuration for UI rendering.

type UIMode

type UIMode int

UIMode represents the output mode for the CLI. The mode determines how output is rendered to the user.

const (
	// ModeAuto detects the appropriate mode based on environment
	// (TTY detection, CI environment, flags).
	ModeAuto UIMode = iota

	// ModeConsole renders output using Lip Gloss styled text
	// for human-friendly console output.
	ModeConsole

	// ModeJSON renders output as structured JSON for scripting
	// and automation.
	ModeJSON

	// ModeTUI launches interactive Terminal UI using Bubble Tea
	// (coming in Phase 4).
	ModeTUI
)

func DetectMode

func DetectMode(cfg UIConfig) UIMode

DetectMode determines the appropriate UI mode based on configuration and environment. Detection priority (highest to lowest):

  1. JSON set → returns ModeJSON (for scripting/automation)
  2. Interactive set → returns ModeTUI (force interactive)
  3. cfg.Mode (if not ModeAuto) → returns explicitly set mode
  4. NO_COLOR, CI environment, or non-TTY → returns ModeConsole
  5. Default → returns ModeConsole (TUI coming in Phase 4)

func (UIMode) String

func (m UIMode) String() string

String returns the string representation of UIMode.

Jump to

Keyboard shortcuts

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