ui

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

func Env

func Env(desc, envVar string) string

Env wraps a description with a dimmed env-var hint.

func PromptPassword added in v1.4.1

func PromptPassword(prompt string) (string, error)

PromptPassword prompts the user for a password on the terminal without echoing.

func PromptPasswordConfirm added in v1.9.0

func PromptPasswordConfirm(msg string) (string, error)

PromptPasswordConfirm prompts for a password and then a confirmation. Returns an error if they don't match or are empty.

func Style added in v1.17.0

func Style(color, text string) string

Style wraps text in the given color, resetting after it.

Types

type ConsoleReporter

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

ConsoleReporter implements Reporter using go-pretty for console output.

func NewConsoleReporter

func NewConsoleReporter() *ConsoleReporter

func (*ConsoleReporter) SetLogWriter

func (c *ConsoleReporter) SetLogWriter(w *SafeLogWriter)

SetLogWriter registers a SafeLogWriter that will be kept in sync with the active progress writer so external log lines (e.g. store debug output) render cleanly above the progress bar.

func (*ConsoleReporter) StartPhase

func (c *ConsoleReporter) StartPhase(name string, total int64, isBytes bool) Phase

type NoOpReporter

type NoOpReporter struct{}

NoOpReporter implements Reporter doing nothing (for tests or silent mode).

func NewNoOpReporter

func NewNoOpReporter() *NoOpReporter

func (*NoOpReporter) StartPhase

func (n *NoOpReporter) StartPhase(name string, total int64, isBytes bool) Phase

type Phase

type Phase interface {
	Increment(n int64)
	Log(msg string)
	Done()
	Error()
}

Phase represents an active progress tracking phase.

type Reporter

type Reporter interface {
	// StartPhase starts a new progress tracking phase.
	// name: Description of the phase.
	// total: Total items/bytes to process. 0 for indeterminate.
	// isBytes: If true, units are bytes, otherwise count.
	StartPhase(name string, total int64, isBytes bool) Phase
}

Reporter defines the interface for progress reporting.

type SafeLogWriter

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

SafeLogWriter is an io.Writer that coexists with go-pretty progress bars. When a progress writer is active, lines are routed through pw.Log() so they render above the bar. Otherwise lines go straight to stderr.

func (*SafeLogWriter) ClearActive

func (w *SafeLogWriter) ClearActive()

ClearActive unregisters the progress writer.

func (*SafeLogWriter) SetActive

func (w *SafeLogWriter) SetActive(pw progress.Writer)

SetActive registers the progress writer that is currently rendering.

func (*SafeLogWriter) Write

func (w *SafeLogWriter) Write(p []byte) (n int, err error)

type TermWriter

type TermWriter struct{ W io.Writer }

TermWriter provides helpers for styled terminal output.

func NewTermWriter

func NewTermWriter(w io.Writer) TermWriter

NewTermWriter returns a TermWriter targeting the given writer.

func (TermWriter) Blank

func (t TermWriter) Blank()

func (TermWriter) Command

func (t TermWriter) Command(name, args string)

func (TermWriter) Commands

func (t TermWriter) Commands(cmds [][2]string)

func (TermWriter) Examples

func (t TermWriter) Examples(cmds ...string)

func (TermWriter) Flags

func (t TermWriter) Flags(flags [][2]string)

func (TermWriter) Heading

func (t TermWriter) Heading(title string)

func (TermWriter) HeadingSub

func (t TermWriter) HeadingSub(title, subtitle string)

func (TermWriter) Note

func (t TermWriter) Note(lines ...string)

Jump to

Keyboard shortcuts

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