Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: LGPL-2.1 Imports: 9 Imported by: 0

Documentation

Overview

Package ui is mcp's light output layer: three decoration modes (Rich, Plain, JSON) over the go-gitmoji-cli UI stack (bubbletea, bubbles, lipgloss).

The wrapper contains no rendering logic of its own beyond mode switches and icon constants. go-gitmoji-cli/pkg/ui itself exports only interactive full-screen flows (CommitPrompt, ListRun, TextInputsRun, ConfirmationRun) and a Spinner hard-wired to os.Stdout and os.Exit; its style helpers are unexported. The wrapper therefore calls through to the same components pkg/ui is built on: RunWithSpinner drives bubbles/spinner + bubbletea with pkg/ui's exact spinner configuration (Dot glyphs, pink 205) but aimed at stderr, and the step prefix reuses pkg/ui's pink accent via lipgloss.

Every Step/Success/Fail line goes to the writer the caller passes (stderr in production), RunWithSpinner decorates stderr, and JSON mode writes nothing at all.

Index

Constants

View Source
const (
	IconSuccess = "✅"
	IconFail    = "❌"
	IconWarn    = "⚠️"
)

Rich-mode icons.

Variables

View Source
var Current = Rich

Current selects how the package decorates output. The cli layer sets it from the global flags; tests set it directly. The zero value is Rich.

Functions

func Fail

func Fail(w io.Writer, format string, args ...any)

Fail reports a failed unit of work: "❌ msg" in Rich, "ERROR: msg" in Plain, nothing in JSON.

func RunWithSpinner

func RunWithSpinner(ctx context.Context, label string, fn func(ctx context.Context) error) error

RunWithSpinner runs fn, passing ctx through unchanged, decorating the wait according to Current. Rich animates "<spinner> label…" on stderr and finishes with "✅ label done in <dur>" or "❌ label failed: <err>"; Plain prints a start line and an end line with duration/error; JSON only runs fn. fn's error propagates in every mode.

func SetSpinnerOutput

func SetSpinnerOutput(w io.Writer) (restore func())

SetSpinnerOutput redirects spinner decoration to w and returns a restore function that puts stderr back. Production code never calls it; tests in other packages use it to capture the decoration that normally goes to stderr.

func Step

func Step(w io.Writer, format string, args ...any)

Step announces the beginning of a unit of work: a styled "==> msg" line in Rich, a plain "==> msg" line in Plain, nothing in JSON.

func Success

func Success(w io.Writer, format string, args ...any)

Success reports a completed unit of work: "✅ msg" in Rich, "OK: msg" in Plain, nothing in JSON.

Types

type Mode

type Mode int

Mode selects the decoration level for every function in this package.

const (
	// Rich is the default: emoji icons, ANSI styles, animated spinner.
	Rich Mode = iota
	// Plain restricts output to ASCII: no emoji, no ANSI escape sequences.
	Plain
	// JSON writes nothing; the caller owns all output.
	JSON
)

Jump to

Keyboard shortcuts

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