ui

package
v1.2.1 Latest Latest
Warning

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

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

Documentation

Overview

Package ui provides user interface utilities.

Index

Constants

This section is empty.

Variables

View Source
var ColorMap = map[string]lipgloss.Color{
	"black":   lipgloss.Color("#000000"),
	"red":     lipgloss.Color("#FF0000"),
	"green":   lipgloss.Color("#00FF00"),
	"yellow":  lipgloss.Color("#FFFF00"),
	"blue":    lipgloss.Color("#0000FF"),
	"magenta": lipgloss.Color("#FF00FF"),
	"cyan":    lipgloss.Color("#00FFFF"),
	"white":   lipgloss.Color("#FFFFFF"),
}

ColorMap maps color names to their lipgloss.Color values

Functions

func AskYesNo

func AskYesNo(prompt string, defaultYes bool, output io.Writer) (bool, error)

AskYesNo prompts the user with a yes/no question and returns their response.

This function displays a prompt to the user and reads their input from stdin. It accepts various forms of yes/no responses: - Yes: "y", "yes", "" (empty for default) - No: "n", "no"

The function is case-insensitive.

Parameters:

  • prompt: The question to display to the user
  • defaultYes: If true, empty input is treated as "yes", otherwise as "no"
  • output: Writer for displaying the prompt (typically os.Stdout or cmd.OutOrStdout())

Returns:

  • bool: true for yes, false for no
  • error: Any error encountered while reading input

Example:

useVPrefix, err := AskYesNo("Use 'v' prefix for version tags?", true, os.Stdout)
if err != nil {
    return err
}

func GetLipglossColor

func GetLipglossColor(col string) (lipgloss.Color, error)

GetLipglossColor converts a color string to a lipgloss.Color

func NewCheckPrinter added in v1.2.0

func NewCheckPrinter(opts ...checkmate.Option) *checkmate.Printer

NewCheckPrinter creates a new checkmate.Printer configured for this project. Use this for check-style output (validations, quality checks, build steps).

Example:

p := ui.NewCheckPrinter()
p.CategoryHeader("Code Quality")
p.CheckHeader("Running linter")
p.CheckSuccess("No issues found")

func NewCheckPrinterWithWriter added in v1.2.0

func NewCheckPrinterWithWriter(w io.Writer, opts ...checkmate.Option) *checkmate.Printer

NewCheckPrinterWithWriter creates a checkmate.Printer that writes to the specified writer.

func PrintColoredMessage

func PrintColoredMessage(out io.Writer, message, col string) error

PrintColoredMessage prints a message to the console with a specific color

func RenderError added in v1.2.0

func RenderError(out io.Writer, friendlyMessage string, err error) error

RenderError prints an error message to the writer (stderr usually) and logs the full error.

Stream 2 (Status): Prints friendly error to out Stream 3 (Audit): Logs full error with stack trace to file

func RenderSuccess added in v1.2.0

func RenderSuccess(out io.Writer, message string, data interface{}) error

RenderSuccess prints a success message to the writer (stdout) and shadows it to the log file.

Stream 1 (Data): Prints formatted message to out Stream 3 (Audit): Logs raw data to file

func StderrCheckPrinter added in v1.2.0

func StderrCheckPrinter() *checkmate.Printer

StderrCheckPrinter returns a checkmate.Printer that writes to stderr.

func StdoutCheckPrinter added in v1.2.0

func StdoutCheckPrinter() *checkmate.Printer

StdoutCheckPrinter returns a checkmate.Printer that writes to stdout. This is a convenience for the common case.

Types

type DefaultUIRunner

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

DefaultUIRunner is the default implementation of UIRunner

func NewDefaultUIRunner added in v1.2.0

func NewDefaultUIRunner() *DefaultUIRunner

NewDefaultUIRunner creates a new DefaultUIRunner with the standard program factory

func NewTestUIRunner added in v1.2.0

func NewTestUIRunner() *DefaultUIRunner

For testing only - allows creating a DefaultUIRunner with a nil program factory This simulates a successful UI run without actually creating a tea.Program

func (*DefaultUIRunner) RunUI

func (d *DefaultUIRunner) RunUI(message, col string) error

RunUI runs the Bubble Tea UI

type MockUIRunner

type MockUIRunner struct {
	CalledWithMessage string
	CalledWithColor   string
	ReturnError       error
}

MockUIRunner is a mock implementation of the UIRunner interface for testing

func (*MockUIRunner) RunUI

func (m *MockUIRunner) RunUI(message, col string) error

type UIRunner

type UIRunner interface {
	RunUI(message, col string) error
}

UIRunner defines an interface for running a UI

Jump to

Keyboard shortcuts

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