ui

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ui is notenv's hand-rolled terminal UI: ANSI styling, prompts, an arrow-key select, and a spinner. Built on x/term raw mode, which is already a dependency, so it adds zero new supply-chain surface.

Styling honors NO_COLOR and TERM=dumb and disables itself off-TTY. All human-facing output goes to stderr; stdout stays reserved for data.

Index

Constants

This section is empty.

Variables

View Source
var ErrCanceled = errors.New("canceled")

ErrCanceled is returned when the user aborts a prompt (Esc, q, Ctrl-C).

Functions

func Bold

func Bold(s string) string

func Confirm

func Confirm(label string, def bool) (bool, error)

Confirm asks a yes/no question.

func Cyan

func Cyan(s string) string

func Dim

func Dim(s string) string

func Failf

func Failf(format string, a ...any)

func Green

func Green(s string) string

func Infof

func Infof(format string, a ...any)

func Input

func Input(label, def string) (string, error)

Input reads one echoed line; empty input returns def.

func Interactive

func Interactive() bool

Interactive reports whether prompts are possible at all.

func Notef

func Notef(format string, a ...any)

func Red

func Red(s string) string

func Select

func Select(label string, options []Option) (int, error)

Select renders an arrow-key picker on the controlling terminal and returns the chosen index. Keys: up/down (or k/j), Enter to choose, Esc/q/Ctrl-C to cancel (returns ErrCanceled). Without a usable raw-mode terminal it falls back to a numbered prompt.

func Spin

func Spin(label string, fn func() error) error

Spin runs fn while animating a spinner on stderr, then reports the outcome as a success or failure status line. Off-TTY it degrades to plain lines.

func Successf

func Successf(format string, a ...any)

func Warnf

func Warnf(format string, a ...any)

func Yellow

func Yellow(s string) string

Types

type Option

type Option struct {
	Label  string
	Detail string
}

Option is one selectable entry; Detail renders dimmed after the label.

Jump to

Keyboard shortcuts

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