Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyOutputConfig(cfg OutputConfig)
- func CaptureOutput(f func()) string
- func CaptureOutputErr(f func() error) (string, error)
- func ClearScreen()
- func DisplayChanges(changes []FieldChange, noColor bool)
- func FormatBool(b bool) string
- func FormatCommandName(name string, noColor bool) string
- func FormatConfirmation(msg string, noColor bool) string
- func FormatExample(example string, noColor bool) string
- func FormatJSONExample(json string, noColor bool) string
- func FormatNewValue(value string, noColor bool) string
- func FormatOldValue(value string, noColor bool) string
- func FormatOptionalFlag(flag string, description string, noColor bool) string
- func FormatOptionalString(s string) string
- func FormatPrompt(msg string, noColor bool) string
- func FormatRequiredFlag(flag string, description string, noColor bool) string
- func FormatSuccess(msg string, noColor bool) string
- func FormatUID(uid string, noColor bool) string
- func GetNoPager() bool
- func GetOutputFormat() string
- func GetTemplateString() string
- func IsQuiet() bool
- func IsTerminal() bool
- func IsVerbose() bool
- func PrintError(format string, noColor bool, args ...interface{})
- func PrintErrorJSON(code int, message string)
- func PrintInfo(format string, noColor bool, args ...interface{})
- func PrintNewline()
- func PrintOutput[T OutputFields](data []T, format string, noColor bool) error
- func PrintPlain(format string, _ bool, args ...interface{})
- func PrintResourceCreated(resourceType, uid string, noColor bool)
- func PrintResourceDeleted(resourceType, uid string, immediate, noColor bool)
- func PrintResourceSuccess(resourceType, action, uid string, noColor bool)
- func PrintResourceUpdated(resourceType, uid string, noColor bool)
- func PrintSuccess(format string, noColor bool, args ...interface{})
- func PrintSuccessWithOutput(format string, noColor bool, outputFormat string, args ...interface{})
- func PrintTableToWriter[T OutputFields](w io.Writer, data []T, noColor bool) error
- func PrintVerbose(format string, noColor bool, args ...interface{})
- func PrintWarning(format string, noColor bool, args ...interface{})
- func ResetState()
- func RunWithPager(fn func() error) error
- func SetIsTerminal(val bool)
- func SetNoHeader(v bool)
- func SetNoPager(v bool)
- func SetOutputFields(fields []string)
- func SetOutputFormat(format string)
- func SetOutputQuery(query string)
- func SetTemplateString(s string)
- func SetTerminalWidthForTesting(width int)
- func SetVerbosity(level string)
- func StripANSIColors(s string) string
- type FieldChange
- type Output
- type OutputConfig
- type OutputFields
- type ResourceTag
- type Spinner
- func NewSpinner(noColor bool) *Spinner
- func NewSpinnerWasm(noColor bool, outputFormat string) *Spinner
- func NewSpinnerWithOutput(noColor bool, outputFormat string) *Spinner
- func PrintCustomSpinner(action, resourceId string, noColor bool) *Spinner
- func PrintListingResourceTags(resourceType, uid string, noColor bool) *Spinner
- func PrintLoggingIn(noColor bool) *Spinner
- func PrintLoggingInWithOutput(noColor bool, outputFormat string) *Spinner
- func PrintResourceCreating(resourceType, uid string, noColor bool) *Spinner
- func PrintResourceDeleting(resourceType, uid string, noColor bool) *Spinner
- func PrintResourceGetting(resourceType, uid string, noColor bool) *Spinner
- func PrintResourceGettingWithOutput(resourceType, uid string, noColor bool, outputFormat string) *Spinner
- func PrintResourceListing(resourceType string, noColor bool) *Spinner
- func PrintResourceProvisioning(resourceType, uid string, noColor bool) *Spinner
- func PrintResourceUpdating(resourceType, uid string, noColor bool) *Spinner
- func PrintResourceValidating(resourceType string, noColor bool) *Spinner
- type SpinnerInterface
Constants ¶
const ( SpinnerStyleDefault = "default" SpinnerStyleWASM = "wasm" SpinnerStyleFancy = "fancy" )
Spinner style constants.
Variables ¶
var ( RadRed = color.New(color.FgRed).Add(color.Bold).SprintFunc() DeepNightBlue = color.New(color.FgBlue).Add(color.FgBlack).SprintFunc() MegaportYellow = color.New(color.FgHiYellow).SprintFunc() MegaportOrange = color.New(color.FgHiRed).SprintFunc() MegaportRed = color.New(color.FgRed).SprintFunc() MegaportPurple = color.New(color.FgMagenta).SprintFunc() RadRedReadable = color.New(color.FgHiRed).Add(color.Bold).SprintFunc() DeepBlueReadable = color.New(color.FgBlue).Add(color.Bold).SprintFunc() YellowReadable = color.New(color.FgYellow).Add(color.Bold).SprintFunc() OrangeReadable = color.New(color.FgRed).Add(color.FgYellow).SprintFunc() PurpleReadable = color.New(color.FgHiMagenta).Add(color.Bold).SprintFunc() NexusBlue = color.New(color.FgBlue).Add(color.Bold).SprintFunc() DodgerBlue = color.New(color.FgHiBlue).Add(color.Bold).SprintFunc() SkyBlue = color.New(color.FgHiCyan).SprintFunc() PurpleCloud = color.New(color.FgMagenta).Add(color.Bold).SprintFunc() Plum = color.New(color.FgHiMagenta).SprintFunc() Mauve = color.New(color.FgHiMagenta).Add(color.Faint).SprintFunc() Pink = color.New(color.FgMagenta).Add(color.Italic).SprintFunc() Magenta = color.New(color.FgHiMagenta).Add(color.Bold).SprintFunc() SunsetOrange = color.New(color.FgRed).Add(color.FgHiYellow).SprintFunc() BlackHole = color.New(color.FgBlack).Add(color.Bold).SprintFunc() DarkBlue = color.New(color.FgBlue).Add(color.Underline).SprintFunc() GoldYellow = color.New(color.FgYellow).Add(color.Bold).SprintFunc() Teal = color.New(color.FgCyan).Add(color.Bold).SprintFunc() LinkGreen = color.New(color.FgGreen).Add(color.Bold).SprintFunc() ElectricLime = color.New(color.FgHiGreen).SprintFunc() )
Functions ¶
func ApplyOutputConfig ¶ added in v0.13.0
func ApplyOutputConfig(cfg OutputConfig)
ApplyOutputConfig atomically replaces the entire output configuration. Fields is deep-copied before storing so that mutations to the caller's slice cannot affect the stored configuration after this call returns.
func CaptureOutput ¶
func CaptureOutput(f func()) string
CaptureOutput runs f and returns everything it writes to stdout. Uses a temporary file instead of an OS pipe to avoid deadlocking when f() produces more output than the pipe buffer can hold. Must not be called reentrantly (the global stdoutMu is not reentrant).
func CaptureOutputErr ¶
func ClearScreen ¶ added in v0.5.8
func ClearScreen()
ClearScreen clears the terminal screen using ANSI escape codes.
func DisplayChanges ¶ added in v0.5.9
func DisplayChanges(changes []FieldChange, noColor bool)
DisplayChanges prints a formatted list of field changes for a resource update. Only changes where OldValue != NewValue are displayed. If no changes are found, a "No changes detected" message is printed.
func FormatBool ¶ added in v0.5.9
FormatBool returns "Yes" or "No" for a boolean value.
func FormatCommandName ¶
func FormatConfirmation ¶
func FormatExample ¶
func FormatJSONExample ¶
func FormatNewValue ¶ added in v0.3.4
func FormatOldValue ¶ added in v0.3.4
func FormatOptionalFlag ¶
func FormatOptionalString ¶ added in v0.5.9
FormatOptionalString returns the string value or "(none)" if empty.
func FormatPrompt ¶
func FormatRequiredFlag ¶
func FormatSuccess ¶
func GetNoPager ¶ added in v0.9.0
func GetNoPager() bool
GetNoPager returns the current no-pager setting. Intended for tests that need to assert the output package was correctly wired by PersistentPreRunE.
func GetOutputFormat ¶ added in v0.9.0
func GetOutputFormat() string
GetOutputFormat returns the currently active output format (e.g. "table", "json").
func GetTemplateString ¶ added in v0.9.0
func GetTemplateString() string
GetTemplateString returns the current Go template string.
func IsQuiet ¶ added in v0.5.3
func IsQuiet() bool
IsQuiet returns true when quiet mode is active. In quiet mode, informational messages and spinners are suppressed.
func IsTerminal ¶ added in v0.5.4
func IsTerminal() bool
IsTerminal returns true if stdout is connected to a terminal (not piped).
func IsVerbose ¶ added in v0.5.3
func IsVerbose() bool
IsVerbose returns true when verbose mode is active.
func PrintError ¶
func PrintErrorJSON ¶ added in v0.9.0
PrintErrorJSON writes a structured JSON error to stderr. Used by RunE wrappers when --output json is active so automation scripts can parse errors programmatically instead of scraping plain text.
func PrintNewline ¶ added in v0.10.0
func PrintNewline()
PrintNewline prints a blank line, suppressed in quiet mode and routed to stderr when the output format is json (consistent with PrintInfo et al.).
func PrintOutput ¶
func PrintOutput[T OutputFields](data []T, format string, noColor bool) error
PrintOutput prints data in the specified format
func PrintPlain ¶ added in v0.10.0
PrintPlain prints a plain line with no icon prefix. Like PrintInfo it is suppressed in quiet mode and routed to stderr in JSON output mode.
func PrintResourceCreated ¶
func PrintResourceDeleted ¶
func PrintResourceSuccess ¶
func PrintResourceUpdated ¶
func PrintSuccess ¶
func PrintSuccessWithOutput ¶ added in v0.4.7
func PrintTableToWriter ¶ added in v0.13.0
func PrintTableToWriter[T OutputFields](w io.Writer, data []T, noColor bool) error
PrintTableToWriter renders data as a table directly to w with no global side effects: it does not page, write to os.Stdout, or set the WASM table global. Use it to compose several tables into one writer (e.g. the status dashboard) so the full output is captured in order, including under the WASM transport where PrintOutput("table") would otherwise only retain the last section. Touching no shared globals, it needs no output-package locking; the caller owns w.
func PrintVerbose ¶ added in v0.5.3
PrintVerbose prints a debug message only when verbose mode is active.
func PrintWarning ¶
func ResetState ¶ added in v0.9.0
func ResetState()
ResetState clears all output configuration back to defaults. Intended for the WASM entry point to prevent state bleed between invocations.
func RunWithPager ¶ added in v0.9.0
RunWithPager runs fn, capturing its stdout output. If stdout is a TTY, the pager is not disabled, and the captured line count exceeds the terminal height, the output is piped through the configured pager. Otherwise the output is written directly to stdout.
Terminal dimensions are read before os.Stdout is redirected so that table rendering (which calls getTerminalWidth via printTable) uses the real TTY width for column layout even while output is being buffered to a temp file. The temp file is streamed rather than loaded into memory, so paging large tables does not require holding the full output in RAM.
func SetIsTerminal ¶ added in v0.5.4
func SetIsTerminal(val bool)
SetIsTerminal overrides the cached TTY detection result. Intended for tests.
func SetNoHeader ¶ added in v0.9.0
func SetNoHeader(v bool)
SetNoHeader sets whether table and CSV output should suppress column headers.
func SetNoPager ¶ added in v0.9.0
func SetNoPager(v bool)
SetNoPager disables or enables the pager. When true, output is always written directly to stdout even if it exceeds the terminal height.
func SetOutputFields ¶ added in v0.5.8
func SetOutputFields(fields []string)
SetOutputFields sets the field filter applied by all PrintOutput calls. Pass nil to restore full output (all fields). The slice is deep-copied so subsequent mutations to fields do not affect the stored config.
func SetOutputFormat ¶ added in v0.4.7
func SetOutputFormat(format string)
func SetOutputQuery ¶ added in v0.5.8
func SetOutputQuery(query string)
SetOutputQuery sets the JMESPath query applied by printJSON. Pass "" to disable.
func SetTemplateString ¶ added in v0.9.0
func SetTemplateString(s string)
SetTemplateString sets the Go template string applied by printGoTemplate. Pass "" to disable.
func SetTerminalWidthForTesting ¶ added in v0.10.0
func SetTerminalWidthForTesting(width int)
SetTerminalWidthForTesting pins the terminal width used by table rendering. Pass 0 to restore auto-detection. Intended for tests only.
func SetVerbosity ¶ added in v0.5.3
func SetVerbosity(level string)
SetVerbosity sets the global verbosity level ("normal", "quiet", or "verbose").
func StripANSIColors ¶
Types ¶
type FieldChange ¶ added in v0.5.9
FieldChange represents a single field that changed between two versions of a resource.
type Output ¶
type Output interface {
// contains filtered or unexported methods
}
Output is a marker interface embedded by output structs.
type OutputConfig ¶ added in v0.9.1
type OutputConfig struct {
Fields []string // nil = show all
Query string // JMESPath; "" = disabled
NoHeader bool
Template string // Go template; "" = disabled
NoPager bool
Format string // "table"|"json"|"csv"|"xml"|"go-template"
Verbosity string // "normal"|"quiet"|"verbose"
}
OutputConfig holds all user-facing output configuration as a single struct. Use ApplyOutputConfig to write and GetOutputConfig to read atomically.
func GetOutputConfig ¶ added in v0.13.0
func GetOutputConfig() OutputConfig
GetOutputConfig returns a snapshot of the current output configuration. Fields is deep-copied so that mutations to the returned slice cannot affect the stored configuration.
type OutputFields ¶
type OutputFields interface {
any
}
OutputFields is a constraint for types that can be output
type ResourceTag ¶ added in v0.4.3
type ResourceTag struct {
Key string `json:"key" header:"Key"`
Value string `json:"value" header:"Value"`
}
ResourceTag represents a key-value tag pair
type Spinner ¶ added in v0.4.0
type Spinner struct {
// contains filtered or unexported fields
}
func NewSpinner ¶ added in v0.4.0
func NewSpinnerWasm ¶ added in v0.4.9
NewSpinnerWasm creates a spinner optimized for WASM display This is the non-WASM build version that uses the regular spinner
func NewSpinnerWithOutput ¶ added in v0.4.7
func PrintCustomSpinner ¶ added in v0.4.4
func PrintListingResourceTags ¶ added in v0.4.3
func PrintLoggingIn ¶ added in v0.4.3
func PrintLoggingInWithOutput ¶ added in v0.4.7
func PrintResourceCreating ¶ added in v0.4.0
func PrintResourceDeleting ¶ added in v0.4.0
func PrintResourceGetting ¶ added in v0.4.0
func PrintResourceGettingWithOutput ¶ added in v0.4.7
func PrintResourceListing ¶ added in v0.4.0
func PrintResourceProvisioning ¶ added in v0.5.6
func PrintResourceUpdating ¶ added in v0.4.0
func PrintResourceValidating ¶ added in v0.4.3
func (*Spinner) StartWithElapsed ¶ added in v0.5.6
StartWithElapsed starts the spinner, appending "(Xs elapsed)" to the prefix each animation tick.
func (*Spinner) StopWithSuccess ¶ added in v0.4.0
type SpinnerInterface ¶ added in v0.4.9
type SpinnerInterface interface {
Start(message string)
Stop()
}
SpinnerInterface allows different spinner implementations (WASM vs native)