Documentation
¶
Overview ¶
Package ui provides user interface utilities.
Index ¶
- Variables
- func AskYesNo(prompt string, defaultYes bool, output io.Writer) (bool, error)
- func GetLipglossColor(col string) (lipgloss.Color, error)
- func NewCheckPrinter(opts ...checkmate.Option) *checkmate.Printer
- func NewCheckPrinterWithWriter(w io.Writer, opts ...checkmate.Option) *checkmate.Printer
- func PrintColoredMessage(out io.Writer, message, col string) error
- func RenderError(out io.Writer, friendlyMessage string, err error) error
- func RenderSuccess(out io.Writer, message string, data interface{}) error
- func StderrCheckPrinter() *checkmate.Printer
- func StdoutCheckPrinter() *checkmate.Printer
- type DefaultUIRunner
- type MockUIRunner
- type UIRunner
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
GetLipglossColor converts a color string to a lipgloss.Color
func NewCheckPrinter ¶ added in v1.2.0
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
NewCheckPrinterWithWriter creates a checkmate.Printer that writes to the specified writer.
func PrintColoredMessage ¶
PrintColoredMessage prints a message to the console with a specific color
func RenderError ¶ added in v1.2.0
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
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
StderrCheckPrinter returns a checkmate.Printer that writes to stderr.
func StdoutCheckPrinter ¶ added in v1.2.0
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 ¶
MockUIRunner is a mock implementation of the UIRunner interface for testing
func (*MockUIRunner) RunUI ¶
func (m *MockUIRunner) RunUI(message, col string) error