ui

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: AGPL-3.0 Imports: 8 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

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.

Jump to

Keyboard shortcuts

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