ux

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset      = "\033[0m"
	Bold       = "\033[1m"
	Dim        = "\033[2m"
	Red        = "\033[31m"
	Green      = "\033[32m"
	Yellow     = "\033[33m"
	Blue       = "\033[34m"
	Magenta    = "\033[35m"
	Cyan       = "\033[36m"
	White      = "\033[37m"
	BoldRed    = "\033[1;31m"
	BoldGreen  = "\033[1;32m"
	BoldYellow = "\033[1;33m"
	BoldBlue   = "\033[1;34m"
	BoldCyan   = "\033[1;36m"
)

Color codes

Variables

View Source
var (
	SpinnerDots    = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
	SpinnerLine    = []string{"-", "\\", "|", "/"}
	SpinnerBounce  = []string{"⠁", "⠂", "⠄", "⠂"}
	SpinnerGrow    = []string{"▁", "▃", "▄", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▄", "▃"}
	SpinnerCircle  = []string{"◐", "◓", "◑", "◒"}
	SpinnerArrow   = []string{"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"}
	SpinnerDefault = SpinnerDots
)

Spinner frames

View Source
var (
	Version   = "1.0.1"
	BuildDate = "2026-01-25"
	GitCommit = "dev"
)

Version information (set via ldflags or defaults)

View Source
var (
	Quiet   bool
	Verbose bool
	NoColor bool
)

Global settings

Functions

func Box

func Box(text string) string

Box wraps text in a simple box

func C

func C(code string) string

C returns the color code if colors are enabled, empty string otherwise

func Code

func Code(text string) string

Code returns text formatted as code

func ColorEnabled

func ColorEnabled() bool

ColorEnabled returns true if colors should be used

func Debug

func Debug(format string, args ...interface{})

Debug prints a debug message to stderr (only in verbose mode)

func DidYouMean

func DidYouMean(suggestions []string) string

DidYouMean formats a "did you mean" suggestion

func Divider

func Divider(char string, width int)

Divider prints a horizontal divider

func Error

func Error(format string, args ...interface{})

Error prints an error message to stderr

func ErrorWithCommand

func ErrorWithCommand(err string, cmd string)

ErrorWithCommand prints an error with a command suggestion

func ErrorWithSuggestion

func ErrorWithSuggestion(err string, suggestion string)

ErrorWithSuggestion prints an error with a suggestion

func FormatDoctorReport

func FormatDoctorReport(checks []Check) string

FormatDoctorReport formats the doctor check results

func FormatExample

func FormatExample(cmd, desc string) string

FormatExample returns a formatted example

func Header(title string)

Header prints a section header

func Highlight

func Highlight(text string) string

Highlight returns highlighted text

func Info

func Info(format string, args ...interface{})

Info prints an info message to stderr (only in verbose mode)

func IsStderrTTY

func IsStderrTTY() bool

IsStderrTTY returns true if stderr is a terminal

func IsTTY

func IsTTY() bool

IsTTY returns true if stdout is a terminal

func ListItem

func ListItem(name, desc string, nameWidth int)

ListItem prints a list item with optional description

func Status

func Status(format string, args ...interface{})

Status prints a status message (non-quiet mode)

func SubHeader

func SubHeader(title string)

SubHeader prints a sub-section header

func Success

func Success(format string, args ...interface{})

Success prints a success message to stderr

func VersionLong

func VersionLong() string

VersionLong returns detailed version info

func VersionString

func VersionString() string

VersionString returns formatted version info

func Warn

func Warn(format string, args ...interface{})

Warn prints a warning message to stderr

Types

type Check

type Check struct {
	Name    string
	Status  CheckStatus
	Message string
	Detail  string
}

Check represents a diagnostic check result

func Doctor

func Doctor() []Check

Doctor runs all diagnostic checks

type CheckStatus

type CheckStatus int
const (
	CheckOK CheckStatus = iota
	CheckWarn
	CheckFail
	CheckSkip
)

func (CheckStatus) Icon

func (s CheckStatus) Icon() string

func (CheckStatus) String

func (s CheckStatus) String() string

type ProgressBar

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

ProgressBar displays a progress bar

func NewProgressBar

func NewProgressBar(total int, message string) *ProgressBar

NewProgressBar creates a new progress bar

func (*ProgressBar) Done

func (p *ProgressBar) Done()

Done completes the progress bar

func (*ProgressBar) Increment

func (p *ProgressBar) Increment()

Increment increments progress by 1

func (*ProgressBar) SetWidth

func (p *ProgressBar) SetWidth(width int)

SetWidth sets the progress bar width

func (*ProgressBar) Update

func (p *ProgressBar) Update(current int)

Update updates the progress

type Spinner

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

Spinner provides an animated loading indicator

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new spinner with a message

func (*Spinner) SetFrames

func (s *Spinner) SetFrames(frames []string)

SetFrames sets custom spinner frames

func (*Spinner) SetMessage

func (s *Spinner) SetMessage(msg string)

SetMessage updates the spinner message

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop stops the spinner

func (*Spinner) StopFail

func (s *Spinner) StopFail(msg string)

StopFail stops with an error message

func (*Spinner) StopSuccess

func (s *Spinner) StopSuccess(msg string)

StopSuccess stops with a success message

func (*Spinner) StopWithMessage

func (s *Spinner) StopWithMessage(msg string)

StopWithMessage stops and prints a final message

Jump to

Keyboard shortcuts

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