ui

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFunMessages = &FunMessages{
	Cluster: []string{
		"Exploring the AWS universe...",
		"Hunting for clusters across regions...",
		"Surfing the cloud waves...",
		"Mapping your EKS empire...",
		"Launching region scanners...",
		"Targeting your clusters...",
		"Supercharging the search...",
		"Analyzing cluster DNA...",
		"Collecting cloud treasures...",
		"Performing AWS magic tricks...",
		"Querying the cluster overlords...",
		"Decoding EKS hieroglyphics...",
		"Asking AWS nicely for cluster secrets...",
		"Convincing clusters to reveal themselves...",
	},
	Nodegroup: []string{
		"Interrogating EKS nodes... they're staying silent for now",
		"Asking AWS politely for nodegroup secrets...",
		"Counting how many nodes are having an existential crisis...",
		"Checking if the nodes have been doing their AMI homework...",
		"Waiting for AWS to stop procrastinating and return our data...",
		"Convincing stubborn nodes to reveal their status...",
		"Performing digital archaeology on your cluster...",
		"Teaching nodes to communicate in human language...",
		"Decoding the ancient art of EKS hieroglyphics...",
		"Bribing AWS APIs with virtual coffee for faster responses...",
		"Whispering sweet nothings to unresponsive nodegroups...",
		"Negotiating with nodes that refuse to scale...",
		"Analyzing node behavior patterns like a digital therapist...",
	},
	Addon: []string{
		"Hunting for add-ons in the AWS wilderness...",
		"Asking add-ons to introduce themselves politely...",
		"Checking if add-ons are playing hide and seek...",
		"Interrogating the add-on registry...",
		"Convincing shy add-ons to show their versions...",
		"Performing add-on archaeology...",
		"Deciphering add-on compatibility matrices...",
		"Bribing add-ons with virtual upgrades...",
	},
	Health: []string{
		"Checking cluster vital signs...",
		"Performing AWS wellness checkup...",
		"Taking cluster temperature...",
		"Analyzing cluster stress levels...",
		"Consulting the cloud doctor...",
		"Running diagnostic spells...",
		"Checking if your cluster needs vitamins...",
		"Performing digital CPR if needed...",
	},
	Workload: []string{
		"Checking workload disruption safety...",
		"Scanning namespaces for PDB coverage...",
		"Matching PDB selectors to deployments...",
		"Reviewing workload maintenance readiness...",
		"Looking for deployments without disruption budgets...",
	},
	General: []string{
		"Working the AWS magic...",
		"Consulting the cloud spirits...",
		"Performing digital incantations...",
		"Asking AWS very nicely...",
		"Waiting for the cloud gods to respond...",
		"Processing with maximum efficiency...",
		"Doing the technical mumbo jumbo...",
		"Making API calls like a pro...",
	},
}

DefaultFunMessages provides the default set of entertaining messages

Functions

func BadgeFail added in v0.7.0

func BadgeFail() string

BadgeFail renders the red failing-health badge.

func BadgeInProgress added in v0.7.0

func BadgeInProgress() string

BadgeInProgress renders the cyan in-progress badge.

func BadgePass added in v0.7.0

func BadgePass() string

BadgePass renders the green passing-health badge.

func BadgeUnknown added in v0.7.0

func BadgeUnknown() string

BadgeUnknown renders the white unknown-health badge.

func DisplayHealthCheckComplete added in v0.1.8

func DisplayHealthCheckComplete(decision health.Decision)

DisplayHealthCheckComplete displays completion message based on decision

func DisplayHealthCheckStart added in v0.1.8

func DisplayHealthCheckStart(clusterName string)

DisplayHealthCheckStart displays the start of health check process

func DisplayHealthResults added in v0.1.8

func DisplayHealthResults(summary health.HealthSummary)

DisplayHealthResults displays the health check results in the specified format

func ElapsedString added in v0.7.0

func ElapsedString(elapsed time.Duration) string

ElapsedString renders an elapsed duration as green seconds, e.g. "1.2s".

func FormatTreeSummary added in v0.2.2

func FormatTreeSummary(itemCount int, itemType string, duration float64) string

FormatTreeSummary creates a summary line for tree displays

func GetDecisionText added in v0.1.8

func GetDecisionText(decision health.Decision) string

GetDecisionText returns the text representation of decision

func GetHealthDecisionColor added in v0.1.8

func GetHealthDecisionColor(decision health.Decision) func(format string, a ...any) string

GetHealthDecisionColor returns the color function for decision

func GetHealthStatusText added in v0.1.8

func GetHealthStatusText(status health.HealthStatus) string

GetHealthStatusText returns the text representation of health status

func GetStatusColor

func GetStatusColor(status types.UpdateStatus) func(format string, a ...any) string

GetStatusColor returns a color function for the update status

func GetStatusPrefix

func GetStatusPrefix(status types.UpdateStatus) string

GetStatusPrefix returns an appropriate text prefix for the update status

func Outf added in v0.2.1

func Outf(format string, a ...any)

Outf writes formatted output to stdout, ignoring write errors intentionally.

func Outln added in v0.2.1

func Outln(a ...any)

Outln writes a line to stdout, ignoring write errors intentionally.

func PadANSI added in v0.7.0

func PadANSI(s string, width int, align Alignment) string

PadANSI left- or right-aligns a possibly ANSI-colored string to width.

func PlainCell added in v0.7.0

func PlainCell(s string) string

PlainCell prepares a value for tab-separated `-o plain` output: it strips ANSI codes and replaces any embedded tab/newline/carriage-return with a single space. Without this, a cell containing a literal tab or newline (AWS tags, multi-line status/error strings) would split one logical row across columns or physical lines, breaking `awk -F'\t'` / `cut`. (REF-65)

func PlainOutput added in v0.7.0

func PlainOutput() bool

PlainOutput reports whether plain rendering is enabled.

func PrintElapsed added in v0.7.0

func PrintElapsed(elapsed time.Duration)

PrintElapsed prints the standard "Retrieved in X.Xs" line followed by a blank line — the shared trailer between a command's heading and its table.

func PromptContinueWithWarnings added in v0.1.8

func PromptContinueWithWarnings(warnings []string) bool

PromptContinueWithWarnings prompts the user to continue despite warnings. The default is No: this guards a rolling update on a cluster that just failed health warnings, so a bare Enter (or unreadable/closed stdin, as in CI) must not silently proceed.

func RenderProgressBar added in v0.1.8

func RenderProgressBar(score int, status health.HealthStatus) string

RenderProgressBar creates a progress bar string based on score and status

func SetPlainOutput added in v0.7.0

func SetPlainOutput(enabled bool)

SetPlainOutput toggles plain rendering for PTable and DynamicTable.

func StatusColorString added in v0.7.0

func StatusColorString(status string) string

StatusColorString colors a status string according to its category.

func StripANSI added in v0.7.0

func StripANSI(s string) string

StripANSI removes ANSI escape sequences from a string.

func TruncateANSI added in v0.7.0

func TruncateANSI(s string, width int) string

TruncateANSI truncates a possibly ANSI-colored string to width, adding an ellipsis when there is room. Escape sequences are preserved, and when the cut discards a trailing reset code, a reset is appended so the truncated cell's color cannot bleed into the rest of the line.

func VisibleWidth added in v0.7.0

func VisibleWidth(s string) int

VisibleWidth returns the printable terminal width of a string, excluding ANSI escape codes. Width is measured in display cells, not runes, so CJK ideographs and emoji (2 columns) and zero-width/combining marks are counted correctly — otherwise PadANSI/TruncateANSI and the table column math drift on non-ASCII cells. Hardened against malformed sequences with a bounded escape length.

Types

type Alignment added in v0.2.1

type Alignment int

Alignment represents horizontal text alignment within a column.

const (
	AlignLeft Alignment = iota
	AlignRight
)

type Column added in v0.2.1

type Column struct {
	Title string
	Min   int
	Max   int
	Align Alignment
}

Column defines a table column with sizing and alignment rules.

type DynamicRow added in v0.2.2

type DynamicRow struct {
	Key   string
	Value string
}

DynamicRow represents a key-value pair for display

type DynamicTable added in v0.2.2

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

DynamicTable provides automatic width calculation for key-value displays ensuring perfect alignment regardless of content length or ANSI color codes.

func NewDynamicTable added in v0.2.2

func NewDynamicTable() *DynamicTable

NewDynamicTable creates a new dynamic table instance

func (*DynamicTable) Add added in v0.2.2

func (dt *DynamicTable) Add(key, value string) *DynamicTable

Add appends a key-value row to the table

func (*DynamicTable) AddBool added in v0.2.2

func (dt *DynamicTable) AddBool(key string, enabled bool) *DynamicTable

AddBool adds a boolean value with automatic ENABLED/DISABLED coloring

func (*DynamicTable) AddColored added in v0.2.2

func (dt *DynamicTable) AddColored(key string, value string, colorFunc func(string) string) *DynamicTable

AddColored adds a row with colored value for status indication

func (*DynamicTable) AddStatus added in v0.2.2

func (dt *DynamicTable) AddStatus(key, status string) *DynamicTable

AddStatus adds a row with automatic color coding for common status values

func (*DynamicTable) Count added in v0.2.2

func (dt *DynamicTable) Count() int

Count returns the number of rows in the table

func (*DynamicTable) IsEmpty added in v0.2.2

func (dt *DynamicTable) IsEmpty() bool

IsEmpty returns true if the table has no rows

func (*DynamicTable) Render added in v0.2.2

func (dt *DynamicTable) Render()

Render prints the table with perfect alignment. Under `-o plain` it emits uncolored "key\tvalue" lines instead.

func (*DynamicTable) RenderSection added in v0.2.2

func (dt *DynamicTable) RenderSection(sectionTitle string)

RenderSection renders the table with a section header

type FunMessages added in v0.2.2

type FunMessages struct {
	Cluster   []string
	Nodegroup []string
	Addon     []string
	General   []string
	Health    []string
	Workload  []string
}

FunMessages provides categorized entertaining messages for different operations

func (*FunMessages) GetMessages added in v0.2.2

func (fm *FunMessages) GetMessages(category string) []string

GetMessages returns messages for the specified category, falling back to general.

type FunSpinner added in v0.2.2

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

FunSpinner provides an entertaining spinner with rotating messages

func NewFunSpinner added in v0.2.2

func NewFunSpinner(messages []string) *FunSpinner

NewFunSpinner creates a spinner that rotates through fun messages

func NewFunSpinnerForCategory added in v0.2.2

func NewFunSpinnerForCategory(category string) *FunSpinner

NewFunSpinnerForCategory creates a fun spinner with messages for a specific category

func (*FunSpinner) Start added in v0.2.2

func (fs *FunSpinner) Start() error

Start begins the fun spinner with rotating messages. When output is not an interactive terminal (CI logs, redirected stderr), no animation is started: the \r and \033[K control sequences would just spam the log. Success still prints its final line.

func (*FunSpinner) Stop added in v0.2.2

func (fs *FunSpinner) Stop()

Stop stops the spinner

func (*FunSpinner) Success added in v0.2.2

func (fs *FunSpinner) Success(message string)

Success completes the spinner with a success message

type PTable added in v0.2.2

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

PTable is a pterm-based table that maintains compatibility with the existing Table interface while solving ANSI alignment issues through pterm's robust table implementation.

func NewPTable added in v0.2.2

func NewPTable(columns []Column, opts ...PTableOption) *PTable

NewPTable creates a new pterm-based table with the given columns and options. This maintains the same interface as the original table but uses pterm internally.

func (*PTable) AddRow added in v0.2.2

func (t *PTable) AddRow(cells ...string)

AddRow appends a row. The number of cells must match the number of columns; mismatched rows are dropped with a stderr warning (silent data loss in a table is much harder to debug than a noisy skip).

func (*PTable) Render added in v0.2.2

func (t *PTable) Render()

Render prints the table using pterm. Column Max is enforced with ANSI-aware truncation, and Min/Align are honored by pre-padding cells to the computed column width (pterm itself only left-aligns).

Under `-o plain` (see ui.SetPlainOutput) the table is rendered as uncolored, tab-separated rows instead.

type PTableOption added in v0.2.2

type PTableOption func(*PTable)

PTableOption configures optional rendering behavior for a PTable.

func CyanHeaders added in v0.7.0

func CyanHeaders() PTableOption

CyanHeaders returns the standard cyan header-color option used by all command tables.

func WithPTableHeaderColor added in v0.2.2

func WithPTableHeaderColor(fn func(string) string) PTableOption

WithPTableHeaderColor sets a coloring function used for header titles.

type RegionTreeBuilder added in v0.2.2

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

RegionTreeBuilder specializes in multi-region organization

func NewRegionTreeBuilder added in v0.2.2

func NewRegionTreeBuilder() *RegionTreeBuilder

NewRegionTreeBuilder creates a specialized region organization builder

func (*RegionTreeBuilder) AddClusterToRegion added in v0.2.2

func (rtb *RegionTreeBuilder) AddClusterToRegion(name, status string, nodeCount int32) *RegionTreeBuilder

AddClusterToRegion adds a cluster to the current region. Clusters always nest one level beneath their region header (AddRoot resets the level to 0, so relying on the current level would render clusters as region siblings).

func (*RegionTreeBuilder) AddRegion added in v0.2.2

func (rtb *RegionTreeBuilder) AddRegion(name string, clusterCount int) *RegionTreeBuilder

AddRegion adds a region root node

func (*RegionTreeBuilder) FinishRegion added in v0.2.2

func (rtb *RegionTreeBuilder) FinishRegion() *RegionTreeBuilder

FinishRegion moves back to the root level for next region

func (*RegionTreeBuilder) RenderWithTitle added in v0.2.2

func (rtb *RegionTreeBuilder) RenderWithTitle(title string) error

RenderWithTitle outputs the region tree with a title

type StatusCategory added in v0.7.0

type StatusCategory int

StatusCategory classifies a free-form status string for rendering.

const (
	StatusNeutral StatusCategory = iota
	StatusGood
	StatusWarning
	StatusBad
	StatusInProgress
	StatusUnknown
)

func ClassifyStatus added in v0.7.0

func ClassifyStatus(status string) StatusCategory

ClassifyStatus maps common AWS/Kubernetes status vocabulary to a render category. This is THE status->category table; per-renderer copies drift.

type TreeBuilder added in v0.2.2

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

TreeBuilder provides a fluent API for constructing hierarchical displays

func NewTreeBuilder added in v0.2.2

func NewTreeBuilder() *TreeBuilder

NewTreeBuilder creates a new tree builder with pre-allocated capacity

func (*TreeBuilder) AddRoot added in v0.2.2

func (tb *TreeBuilder) AddRoot(text string) *TreeBuilder

AddRoot adds a root node to the tree

func (*TreeBuilder) AddStatus added in v0.2.2

func (tb *TreeBuilder) AddStatus(icon, text, status string) *TreeBuilder

AddStatus adds a status-colored node

func (*TreeBuilder) Render added in v0.2.2

func (tb *TreeBuilder) Render() error

Render outputs the tree to the console

func (*TreeBuilder) RenderWithTitle added in v0.2.2

func (tb *TreeBuilder) RenderWithTitle(title string) error

RenderWithTitle outputs the tree with a section title

func (*TreeBuilder) UpTo added in v0.2.2

func (tb *TreeBuilder) UpTo(level int) *TreeBuilder

UpTo moves up to a specific level

Jump to

Keyboard shortcuts

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