ui

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IconSuccess = "✓"
	IconError   = "✗"
	IconWarning = "⚠"
	IconInfo    = "▸"
	IconBrand   = "✦"
	IconArrow   = "→"
	IconDot     = "·"
)

Icon constants

Variables

View Source
var (
	ColorBrand   = lipgloss.Color("#7C3AED") // Purple
	ColorSuccess = lipgloss.Color("#10B981") // Green
	ColorWarning = lipgloss.Color("#F59E0B") // Amber
	ColorError   = lipgloss.Color("#EF4444") // Red
	ColorMuted   = lipgloss.Color("#6B7280") // Gray
	ColorInfo    = lipgloss.Color("#3B82F6") // Blue
	ColorWhite   = lipgloss.Color("#F9FAFB") // Off-white
	ColorDim     = lipgloss.Color("#4B5563") // Dark gray
)

Brand colors

View Source
var (
	StyleTitle = lipgloss.NewStyle().
				Foreground(ColorBrand).
				Bold(true)

	StyleSubtitle = lipgloss.NewStyle().
					Foreground(ColorWhite).
					Bold(true)

	StyleBody = lipgloss.NewStyle().
				Foreground(ColorWhite)

	StyleCode = lipgloss.NewStyle().
				Foreground(ColorInfo)

	StyleDim = lipgloss.NewStyle().
				Foreground(ColorMuted)

	StyleBold = lipgloss.NewStyle().
				Foreground(ColorWhite).
				Bold(true)

	StyleSuccess = lipgloss.NewStyle().
					Foreground(ColorSuccess)

	StyleWarning = lipgloss.NewStyle().
					Foreground(ColorWarning)

	StyleError = lipgloss.NewStyle().
				Foreground(ColorError)

	StyleBrand = lipgloss.NewStyle().
				Foreground(ColorBrand).
				Bold(true)
)

Text styles

View Source
var (
	BoxStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorMuted).
				Padding(0, 1)

	ErrorBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(ColorError).
					Padding(0, 1)

	SuccessBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(ColorSuccess).
					Padding(0, 1)
)

Box styles

Functions

func Banner(version string) string

Banner prints the DevContract ASCII art banner.

func Blank

func Blank()

Blank prints a blank line.

func BrandIcon

func BrandIcon() string

Formatted icon helpers

func Code

func Code(text string)

Code prints text styled as code.

func ConfirmAction

func ConfirmAction(prompt string, defaultYes bool) bool

ConfirmAction asks the user for a yes/no confirmation using bubbletea.

func Error

func Error(msg string)

Error prints an error line.

func ErrorIcon

func ErrorIcon() string
func Header(title string)

Header prints a formatted section header.

func Indent

func Indent(s string) string

Indent adds consistent left padding.

func IndentBy

func IndentBy(s string, n int) string

IndentBy adds n spaces of left padding.

func InfoIcon

func InfoIcon() string

func Line

func Line(text string)

Line prints the given text indented.

func MaskValue

func MaskValue(v string) string

MaskValue shows first 4 and last 2 chars, masks the middle.

func NoColor

func NoColor() bool

NoColor returns true if color output should be suppressed.

func PrintTable

func PrintTable(titles []string, rows [][]string)

PrintTable is a convenience function.

func PromptAcceptAll

func PromptAcceptAll() bool

PromptAcceptAll asks if the user wants to accept all remaining changes.

func RenderDiff

func RenderDiff(diff *envfile.DiffResult) string

RenderDiff displays a color-coded diff between two env files.

func RenderDiffSummary

func RenderDiffSummary(diff *envfile.DiffResult) string

RenderDiffSummary returns a one-line summary of changes.

func RenderError

func RenderError(e StructuredError)

RenderError displays a structured error with full context.

func SetNoColor

func SetNoColor(enabled bool)

SetNoColor configures process-wide no-color behavior for lipgloss rendering.

func SetQuiet

func SetQuiet(enabled bool)

SetQuiet configures whether non-error UI output should be suppressed.

func Status

func Status(msg string)

Status prints a status line with an icon.

func Success

func Success(msg string)

Success prints a success line.

func SuccessIcon

func SuccessIcon() string

func TerminalWidth

func TerminalWidth() int

TerminalWidth returns the current terminal width, defaulting to 80.

func Warning

func Warning(msg string)

Warning prints a warning line.

func WarningIcon

func WarningIcon() string

func WithSpinner

func WithSpinner(message string, fn func() error) error

WithSpinner runs a function with an animated spinner.

Types

type Column

type Column struct {
	Title string
	Width int // 0 = auto
}

Column defines a table column.

type ConflictItem

type ConflictItem struct {
	Key        string
	BaseValue  string
	OurValue   string
	TheirValue string
	Resolved   bool
	Decision   MergeChoice
	EditValue  string
}

ConflictItem represents a single merge conflict for the TUI.

type ErrorCategory

type ErrorCategory string

ErrorCategory classifies an error for UX purposes.

const (
	ErrNetwork ErrorCategory = "network"
	ErrAuth    ErrorCategory = "auth"
	ErrConfig  ErrorCategory = "config"
	ErrFile    ErrorCategory = "file"
	ErrCrypto  ErrorCategory = "crypto"
	ErrRelay   ErrorCategory = "relay"
	ErrSync    ErrorCategory = "sync"
)

type MergeChoice

type MergeChoice int

MergeChoice represents the user's decision for a single variable.

const (
	MergeAccept MergeChoice = iota
	MergeReject
	MergeEdit
	MergeSkip
)

type MergeDecision

type MergeDecision struct {
	Key       string
	Choice    MergeChoice
	EditValue string
}

MergeDecision is the result of a per-variable merge prompt.

func PromptMerge

func PromptMerge(key, oldValue, newValue string) MergeDecision

PromptMerge displays a per-variable merge prompt with bubbletea navigation.

type MergeTUIResult

type MergeTUIResult struct {
	Conflicts []ConflictItem
	Aborted   bool
}

MergeTUIResult is the output of the interactive merge TUI.

func RunMergeTUI

func RunMergeTUI(conflicts []ConflictItem) MergeTUIResult

RunMergeTUI launches the full-screen interactive merge conflict resolver.

type Spinner

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

Spinner displays an animated bubbletea spinner.

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new bubbletea-powered spinner.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop halts the spinner.

func (*Spinner) StopError

func (s *Spinner) StopError(msg string)

StopError shows an error message.

func (*Spinner) StopSuccess

func (s *Spinner) StopSuccess(msg string)

StopSuccess shows a success message.

func (*Spinner) StopWithMessage

func (s *Spinner) StopWithMessage(msg string)

StopWithMessage halts the spinner and shows a message.

func (*Spinner) UpdateMessage

func (s *Spinner) UpdateMessage(msg string)

UpdateMessage changes the displayed message.

type StructuredError

type StructuredError struct {
	Category   ErrorCategory
	Message    string
	Cause      string
	Suggestion string
	DocsURL    string
}

StructuredError is a user-facing error with context.

func ErrEnvFileNotFound

func ErrEnvFileNotFound(path string) StructuredError

ErrEnvFileNotFound returns a structured error for missing .env file.

func ErrFingerprintMismatch

func ErrFingerprintMismatch(expected, got string) StructuredError

ErrFingerprintMismatch returns a structured error for key mismatch.

func ErrNoPeers

func ErrNoPeers() StructuredError

ErrNoPeers returns a structured error when no peers are found.

func ErrNoSSHKey

func ErrNoSSHKey(path string) StructuredError

ErrNoSSHKey returns a structured error for missing SSH key.

func ErrNotInitialized

func ErrNotInitialized() StructuredError

ErrNotInitialized returns a structured error for uninitialized project.

func ErrRelayUnavailable

func ErrRelayUnavailable(cause string) StructuredError

ErrRelayUnavailable returns a structured error for relay failure.

type Table

type Table struct {
	Columns []Column
	Rows    [][]string
}

Table renders a formatted table.

func NewTable

func NewTable(titles ...string) *Table

NewTable creates a table with the given column titles.

func (*Table) AddRow

func (t *Table) AddRow(values ...string)

AddRow adds a row to the table.

func (*Table) Render

func (t *Table) Render() string

Render returns the formatted table string.

Jump to

Keyboard shortcuts

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