Documentation
¶
Overview ¶
Package ui provides styled terminal output and interactive prompts.
Index ¶
- Variables
- func Code(s string) string
- func ConfirmDelete(name, id string, repos []DeleteRepo) (bool, error)
- func ConfirmReset(filePath string) (bool, error)
- func Error(msg string)
- func Errorf(format string, a ...any)
- func FormatDuration(ms int64) string
- func Info(msg string)
- func Print(msg string)
- func Printf(format string, a ...any)
- func RelativeTime(t time.Time) string
- func RunStatusTable(rows []StatusRow, display StatusDisplayConfig, ...) ([]string, error)
- func RunWithSpinner(title string, op SpinnerOp) error
- func SelectAgent(agents []AgentOption) (string, error)
- func SelectWorkspace(matches []WorkspaceOption) (string, error)
- func SetPlain(v bool)
- func StatusStyle(status string, colorMap map[string]string) string
- func Success(msg string)
- func Table(headers []string, rows [][]string) string
- func Truncate(s string, maxLen int) string
- func Warning(msg string)
- type AgentOption
- type DeleteRepo
- type SpinnerOp
- type StatusDisplayConfig
- type StatusResolvedMsg
- type StatusRow
- type WorkspaceOption
Constants ¶
This section is empty.
Variables ¶
var ErrInterrupted = errors.New("interrupted")
ErrInterrupted is returned when the spinner is cancelled via ctrl+c.
Functions ¶
func ConfirmDelete ¶
func ConfirmDelete(name, id string, repos []DeleteRepo) (bool, error)
ConfirmDelete prompts the user to confirm workspace deletion.
func ConfirmReset ¶ added in v1.0.0
ConfirmReset prompts the user to confirm resetting a file to its default value.
func FormatDuration ¶ added in v1.3.0
FormatDuration formats a duration as a short human-readable string.
func RelativeTime ¶
RelativeTime returns a human-friendly relative time string.
func RunStatusTable ¶ added in v1.3.0
func RunStatusTable(rows []StatusRow, display StatusDisplayConfig, resolve func(send func(StatusResolvedMsg))) ([]string, error)
RunStatusTable displays a live-updating table in TTY mode. The resolve function runs concurrently and sends StatusResolvedMsg via send as each workspace status is determined. In non-TTY mode, resolve runs to completion and a static table is printed. Returns the resolved statuses indexed by row.
func RunWithSpinner ¶
RunWithSpinner runs op while displaying an animated spinner in TTY mode. In non-TTY mode it falls back to plain text output.
func SelectAgent ¶ added in v1.0.0
func SelectAgent(agents []AgentOption) (string, error)
SelectAgent prompts the user to choose among multiple configured agents. Returns the selected agent's exec command.
func SelectWorkspace ¶
func SelectWorkspace(matches []WorkspaceOption) (string, error)
SelectWorkspace prompts the user to choose among multiple matching workspaces. Returns the selected workspace's ID.
func StatusStyle ¶ added in v1.3.0
StatusStyle returns the status string with color applied. Colors are looked up from the provided colorMap (status name → ANSI code). Falls back to uncolored text if no color is defined for the status.
Types ¶
type AgentOption ¶ added in v1.0.0
AgentOption represents an agent choice for interactive selection.
type DeleteRepo ¶
DeleteRepo holds repo display info for the delete confirmation prompt.
type SpinnerOp ¶
SpinnerOp is the function executed while the spinner is displayed. Call report to emit progress lines shown below the spinner.
type StatusDisplayConfig ¶ added in v1.4.0
type StatusDisplayConfig struct {
Order map[string]int // status name → display sort index
Colors map[string]string // status name → ANSI color code
}
StatusDisplayConfig holds spec-derived display settings for the status table.
type StatusResolvedMsg ¶ added in v1.3.0
StatusResolvedMsg signals that a row's status has been resolved.