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
- Variables
- func Fail(w io.Writer, format string, args ...any)
- func RunWithSpinner(ctx context.Context, label string, fn func(ctx context.Context) error) error
- func SetSpinnerOutput(w io.Writer) (restore func())
- func Step(w io.Writer, format string, args ...any)
- func Success(w io.Writer, format string, args ...any)
- type Mode
Constants ¶
const ( IconSuccess = "✅" IconFail = "❌" IconWarn = "⚠️" )
Rich-mode icons.
Variables ¶
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 ¶
Fail reports a failed unit of work: "❌ msg" in Rich, "ERROR: msg" in Plain, nothing in JSON.
func RunWithSpinner ¶
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 ¶
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.