Documentation
¶
Index ¶
- Constants
- func AskSecret(question string) (string, error)
- func Bold(s string) string
- func Color(s string, color string) string
- func Confirm(question string) (bool, error)
- func Error(err error) string
- func Failure(message string) string
- func FormattedMap(resource map[string]any) string
- func GetTerminalWidth() int
- func GreyedOut(s string) string
- func IsTerminal() bool
- func NewSpinner(message string) *spinner.Spinner
- func Print(a ...interface{})
- func PrintError(err error)
- func PrintFailure(message string)
- func PrintSuccess(message string)
- func PrintTable(columns []table.Column, rows []table.Row)
- func PrintWarning(message string)
- func Printf(format string, a ...interface{})
- func Println(a ...interface{})
- func Ruler() string
- func RulerWithWidth(width int) string
- func Success(message string) string
- func Warning(message string) string
- type TaskReporter
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func AskSecret ¶
AskSecret asks the user a question and reads the response as a secret. The response is trimmed of leading and trailing whitespace.
func Color ¶
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 Failure ¶ added in v0.12.0
Failure returns a failure message string in a styled format, including a red "x" symbol.
func FormattedMap ¶ added in v0.8.0
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 IsTerminal ¶ added in v0.12.0
func IsTerminal() bool
func NewSpinner ¶
NewSpinner creates and returns a new spinner with the given message.
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 PrintWarning ¶ added in v0.12.0
func PrintWarning(message string)
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
RulerWithWidth returns a string representing a horizontal line of a given width.
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.