ui

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorRed    string = "9"
	ColorGreen  string = "10"
	ColorYellow string = "11"
	ColorWhite  string = "15"
	ColorBlue   string = "12"
	ColorGrey   string = "#999999"
)

Variables

This section is empty.

Functions

func AskSecret

func AskSecret(question string) (string, error)

AskSecret asks the user a question and reads the response as a secret. The response is trimmed of leading and trailing whitespace.

func Bold

func Bold(s string) string

Bold returns the input string styled in bold.

func Color

func Color(s string, color string) string

Color returns the input string styled with the specified color, supported by lipgloss. This can be either an ANSI color (https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) or an RGBA hex code.

func Confirm

func Confirm(question string) (bool, error)

Confirm asks the user a yes/no question and returns their response as a boolean.

func Error added in v0.12.0

func Error(err error) string

func Failure added in v0.12.0

func Failure(message string) string

Failure returns a failure message string in a styled format, including a red "x" symbol.

func FormattedMap added in v0.8.0

func FormattedMap(resource map[string]any) string

FormattedMap formats a single map[string]any resource into a structured, human-readable string.

Formatting applied: - Priority fields (id, name, createdAt, updatedAt) are displayed first - Remaining fields are sorted alphabetically - Column alignment with padding for clean layout - Color coding: IDs in yellow, unset values in grey - Nested objects are indented with proper hierarchy - Column width is calculated based on the longest key in the resource

Designed for displaying detailed information of a single resource in CLI output.

func GetTerminalWidth added in v0.8.0

func GetTerminalWidth() int

GetTerminalWidth returns the current width of the terminal.

func GreyedOut added in v0.8.0

func GreyedOut(s string) string

GreyedOut returns the input string styled in a greyed-out color.

func IsTerminal added in v0.12.0

func IsTerminal() bool

func NewSpinner

func NewSpinner(message string) *spinner.Spinner

NewSpinner creates and returns a new spinner with the given message.

func Print added in v0.12.0

func Print(a ...interface{})

func PrintError added in v0.12.0

func PrintError(err error)

PrintError prints the given error message to stderr in a styled format.

func PrintFailure added in v0.12.0

func PrintFailure(message string)

PrintFailure prints a failure message to stdout in a styled format, including a red "x" symbol.

func PrintSuccess added in v0.12.0

func PrintSuccess(message string)

PrintSuccess prints a success message to stdout in a styled format, including a green checkmark symbol.

func PrintTable added in v0.12.0

func PrintTable(columns []table.Column, rows []table.Row)

func PrintWarning added in v0.12.0

func PrintWarning(message string)

func Printf added in v0.12.0

func Printf(format string, a ...interface{})

func Println added in v0.12.0

func Println(a ...interface{})

func Ruler added in v0.8.0

func Ruler() string

Ruler returns a string representing a horizontal line across the terminal.

func RulerWithWidth added in v0.8.0

func RulerWithWidth(width int) string

RulerWithWidth returns a string representing a horizontal line of a given width.

func Success added in v0.12.0

func Success(message string) string

Success returns a success message string in a styled format, including a green checkmark symbol.

func Warning added in v0.12.0

func Warning(message string) string

Types

type TaskReporter added in v0.12.0

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

TaskReporter manages and displays the progress of multiple tasks in the terminal

func NewTaskReporter added in v0.12.0

func NewTaskReporter(total int) *TaskReporter

func (*TaskReporter) Complete added in v0.12.0

func (t *TaskReporter) Complete(id string, message string, err error)

Complete signals the completion of a task with the given id, message, and error status. Spinners for completed tasks will be removed from the display, and a success or failure message will be printed based on the error status.

func (*TaskReporter) Done added in v0.12.0

func (t *TaskReporter) Done()

Done sends a signal to terminate the TaskReporter UI. This blocks until the UI is finished.

func (*TaskReporter) Run added in v0.12.0

func (t *TaskReporter) Run() error

Run starts the TaskReporter UI. This method blocks until the UI is finished, by calling Done() on the TaskReporter.

func (*TaskReporter) Start added in v0.12.0

func (t *TaskReporter) Start(id string, message string)

Start signals the start of a task with the given id and message. For each started task, a spinner with the message will be displayed.

Jump to

Keyboard shortcuts

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