ui

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: GPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskYesNo

func AskYesNo(r io.Reader, w io.Writer, question string, opts AskOptions) (bool, error)

AskYesNo asks question on w and reads a yes/no response from r. AssumeYes short-circuits to true; NonInteractive (without AssumeYes) short-circuits to false. Default (empty answer) is no. Recognises: y, yes (case-insensitive, trimmed).

func ColorEnabled

func ColorEnabled(w io.Writer, mode ColorMode) bool

ColorEnabled reports whether color/ANSI escapes should be emitted to w.

  • ColorNever or NO_COLOR/COMMITBRIEF_NO_COLOR env set → false
  • ColorAlways → true (caller's choice, even when piped)
  • ColorAuto → true only if w is a TTY

func EnableANSI

func EnableANSI(w io.Writer) error

EnableANSI applies platform-specific tweaks needed to render ANSI escapes (e.g. enabling VT processing on Windows 10+). No-op on POSIX.

func IsStdinTTY

func IsStdinTTY(r io.Reader) bool

IsStdinTTY reports whether the given reader is a TTY. Used by the CLI to decide whether to set AskOptions.NonInteractive automatically.

Types

type AskOptions

type AskOptions struct {
	AssumeYes      bool
	NonInteractive bool
}

type ColorMode

type ColorMode int
const (
	ColorAuto ColorMode = iota
	ColorAlways
	ColorNever
)

func ParseColorMode

func ParseColorMode(s string) ColorMode

type Spinner

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

func NewSpinner

func NewSpinner(w io.Writer, message string) *Spinner

NewSpinner returns a spinner that animates frames in w. When the writer is not a TTY (or NO_COLOR-equivalent is set), the spinner is inert: Start does nothing, Stop does nothing. Callers don't need to branch on TTY state.

func (*Spinner) Start

func (s *Spinner) Start()

func (*Spinner) Stop

func (s *Spinner) Stop()

func (*Spinner) Update

func (s *Spinner) Update(msg string)

type StreamResult

type StreamResult struct {
	Content string
	Usage   provider.Usage
	Err     error
}

StreamResult is the accumulated outcome of draining a provider stream. Content is the full assembled response; Usage is the last reported usage (may be the cumulative final value); Err is non-nil on a stream error.

func Drain

func Drain(ctx context.Context, ch <-chan provider.Event, w io.Writer) StreamResult

Drain consumes events from ch and writes deltas to w as they arrive. Returns when the channel closes, the context is done, or an error event is observed. Safe to call with a nil writer (deltas are still buffered in the returned StreamResult.Content).

Jump to

Keyboard shortcuts

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