ui

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionableError

func ActionableError(streams domain.IOStreams, message string, command string)

func Bold

func Bold(text string) string

func ColorEnabled

func ColorEnabled(streams domain.IOStreams) bool

func Confirm

func Confirm(streams domain.IOStreams, message string) error

Confirm waits for Enter key press.

func Dim

func Dim(text string) string

func Error

func Error(text string) string

func IsTerminal

func IsTerminal(streams domain.IOStreams) bool

IsTerminal returns false for non-file streams (e.g., pipes, test buffers). This is intentional: non-interactive contexts should not prompt for input.

func List

func List(streams domain.IOStreams, items []ListItem, prompt string) (int, error)

List displays a numbered list on stderr and reads selection from stdin. If items > 15, truncates with "... and N more. Refine your search." Returns the selected index (0-based). In non-TTY mode: prints list to stdout (parseable), returns -1 (no selection).

func PrintLogo(streams domain.IOStreams)

PrintLogo displays the ASCII wordmark on stderr.

func Progress

func Progress(streams domain.IOStreams, current, total int, label string)

Progress displays "[##·] 3/5 label" on stderr.

func Prompt

func Prompt(streams domain.IOStreams, question string, defaultVal string) (string, error)

Prompt asks a question with optional default, returns answer.

func ResetColorFromEnv

func ResetColorFromEnv()

ResetColorFromEnv re-reads the NO_COLOR environment variable and updates the color flag accordingly. Call this in tests after t.Setenv("NO_COLOR", ...) to simulate the env-based initialization that init() performs once at startup.

func SaveAndDisableColor

func SaveAndDisableColor() func()

SaveAndDisableColor saves the current color state, disables color output, and returns a restore function that sets colorFlag back to the saved state. Usage in tests: restore := ui.SaveAndDisableColor(); defer restore()

func SetColorEnabled

func SetColorEnabled(enabled bool)

func Success

func Success(text string) string

func Verb

func Verb(streams domain.IOStreams, verb string, message string)

func VerbDelete

func VerbDelete(streams domain.IOStreams, message string)

func Warning

func Warning(text string) string

Types

type ListItem

type ListItem struct {
	Type  string // "decision", "feature", etc.
	Title string // slug or heading
	Date  string // "2026-03-07"
}

ListItem represents one entry in a numbered selection list.

type Renderer

type Renderer interface {
	Progress(current, total int, label string)
	QuestionConfirm(label, value string)
	Result(verb, filename string)
}

Renderer defines the contract for question flow rendering. Two implementations exist:

  • ProgressRenderer (TTY): condensation progressive, bar, checkmarks, ANSI colors
  • LineRenderer (non-TTY): one line per event, no ANSI rewriting, CI/pipe compatible

Current implementations live in workflow/ (ProgressRenderer and LineRenderer). TODO: migrate workflow.ProgressRenderer and workflow.LineRenderer here post-MVP.

type Spinner added in v1.1.0

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

Spinner displays an animated spinner with a label, elapsed time, and optional timeout countdown on stderr.

func StartSpinner added in v1.1.0

func StartSpinner(streams domain.IOStreams, label string) *Spinner

StartSpinner begins a spinner animation with the given label. Shows elapsed time: ⠹ Label… (12s)

func StartSpinnerWithTimeout added in v1.1.0

func StartSpinnerWithTimeout(streams domain.IOStreams, label string, timeout time.Duration) *Spinner

StartSpinnerWithTimeout begins a spinner that also shows a countdown to the configured timeout and warns when 80% has elapsed.

func (*Spinner) Elapsed added in v1.1.0

func (s *Spinner) Elapsed() time.Duration

Elapsed returns the time since the spinner started.

func (*Spinner) Stop added in v1.1.0

func (s *Spinner) Stop()

Stop halts the spinner and clears the line.

func (*Spinner) StopWith added in v1.1.0

func (s *Spinner) StopWith(msg string)

StopWith halts the spinner and prints a final message on the same line.

func (*Spinner) StopWithDuration added in v1.1.0

func (s *Spinner) StopWithDuration(msg string)

StopWithDuration halts the spinner and prints a message with elapsed time.

Jump to

Keyboard shortcuts

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