Documentation
¶
Index ¶
- Variables
- func CaptureOutput(f func()) string
- func CaptureOutputErr(f func() error) (string, error)
- 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 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 PrintError(format string, noColor bool, args ...interface{})
- func PrintInfo(format string, noColor bool, args ...interface{})
- func PrintOutput[T OutputFields](data []T, format string, noColor bool) error
- 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 PrintWarning(format string, noColor bool, args ...interface{})
- func StripANSIColors(s string) string
- type Output
- type OutputFields
- type ResourceTag
- type Spinner
- func NewSpinner(noColor bool) *Spinner
- func PrintCustomSpinner(action, resourceId string, noColor bool) *Spinner
- func PrintListingResourceTags(resourceType, uid string, noColor bool) *Spinner
- func PrintLoggingIn(noColor bool) *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 PrintResourceListing(resourceType string, noColor bool) *Spinner
- func PrintResourceUpdating(resourceType, uid string, noColor bool) *Spinner
- func PrintResourceValidating(resourceType string, noColor bool) *Spinner
Constants ¶
This section is empty.
Variables ¶
var ( // Primary colors RadRed = color.New(color.FgRed).Add(color.Bold).SprintFunc() // #E40046, PMS 192 C, RGB(228,0,70), CMYK(0,100,69,11) DeepNightBlue = color.New(color.FgBlue).Add(color.FgBlack).SprintFunc() // #0C1124, PMS 276 C, RGB(12,17,36), CMYK(67,53,0,86) // Secondary colors MegaportYellow = color.New(color.FgHiYellow).SprintFunc() // #FFBD39 MegaportOrange = color.New(color.FgHiRed).SprintFunc() // #FF4713 MegaportRed = color.New(color.FgRed).SprintFunc() // #DC0032 MegaportPurple = color.New(color.FgMagenta).SprintFunc() // #764394 // Readability-enhanced brand colors (modified for CLI readability while maintaining brand identity) RadRedReadable = color.New(color.FgHiRed).Add(color.Bold).SprintFunc() // Enhanced RadRed for better terminal contrast DeepBlueReadable = color.New(color.FgBlue).Add(color.Bold).SprintFunc() // Enhanced DeepNightBlue for readability YellowReadable = color.New(color.FgYellow).Add(color.Bold).SprintFunc() // Enhanced MegaportYellow OrangeReadable = color.New(color.FgRed).Add(color.FgYellow).SprintFunc() // Enhanced MegaportOrange PurpleReadable = color.New(color.FgHiMagenta).Add(color.Bold).SprintFunc() // Enhanced MegaportPurple // Accent colors NexusBlue = color.New(color.FgBlue).Add(color.Bold).SprintFunc() // #0072DA (PMS 285 C) DodgerBlue = color.New(color.FgHiBlue).Add(color.Bold).SprintFunc() // #1AA0FF (PMS 2925 C) SkyBlue = color.New(color.FgHiCyan).SprintFunc() // #70D9F8 (PMS Blue 0821 C) PurpleCloud = color.New(color.FgMagenta).Add(color.Bold).SprintFunc() // #6500D1 (PMS 267 C) Plum = color.New(color.FgHiMagenta).SprintFunc() // #A555F5 (PMS 265 C) Mauve = color.New(color.FgHiMagenta).Add(color.Faint).SprintFunc() // #C49BF8 (PMS 264 C) Pink = color.New(color.FgMagenta).Add(color.Italic).SprintFunc() // #EA3388 (PMS 1915 C) Magenta = color.New(color.FgHiMagenta).Add(color.Bold).SprintFunc() // #E24BCC (PMS 238 C) SunsetOrange = color.New(color.FgRed).Add(color.FgHiYellow).SprintFunc() // #FF7F32 (PMS 1575 C) BlackHole = color.New(color.FgBlack).Add(color.Bold).SprintFunc() // #000000 (PMS Black C) DarkBlue = color.New(color.FgBlue).Add(color.Underline).SprintFunc() // #200786 (PMS 2735 C) GoldYellow = color.New(color.FgYellow).Add(color.Bold).SprintFunc() // #FAAE3B (PMS 1365 C) Teal = color.New(color.FgCyan).Add(color.Bold).SprintFunc() // #00ACB6 (PMS 7466 C) LinkGreen = color.New(color.FgGreen).Add(color.Bold).SprintFunc() // #00B174 (PMS Bright Green C) ElectricLime = color.New(color.FgHiGreen).SprintFunc() // #61FFB6 (PMS 3375) )
Megaport brand colors (from brand guidelines at https://www.megaport.com/branding/megaport-brand-guidelines.pdf)
Functions ¶
func CaptureOutput ¶
func CaptureOutput(f func()) string
captureOutput captures and returns any output written to stdout during execution of f.
func CaptureOutputErr ¶
captureOutputErr is a helper function to capture stdout output and return any error
func FormatCommandName ¶
FormatCommandName colorizes command names
func FormatConfirmation ¶
FormatConfirmation returns a formatted confirmation prompt
func FormatExample ¶
FormatExample colorizes command examples in help text
func FormatJSONExample ¶
FormatJSONExample formats JSON examples in help text
func FormatNewValue ¶ added in v0.3.4
func FormatOldValue ¶ added in v0.3.4
Helper functions to format old and new values
func FormatOptionalFlag ¶
FormatOptionalFlag formats optional flags in help text
func FormatPrompt ¶
FormatPrompt returns a formatted input prompt
func FormatRequiredFlag ¶
FormatRequiredFlag highlights required flags in help text
func FormatSuccess ¶
FormatSuccess returns a formatted success string
func PrintError ¶
PrintError prints an error message with red color
func PrintOutput ¶
func PrintOutput[T OutputFields](data []T, format string, noColor bool) error
PrintOutput formats data in the specified output style
func PrintResourceCreated ¶
PrintResourceCreated prints a standardized resource creation message
func PrintResourceDeleted ¶
PrintResourceDeleted prints a standardized resource deletion message
func PrintResourceSuccess ¶
PrintResourceSuccess prints a success message for a resource operation
func PrintResourceUpdated ¶
PrintResourceUpdated prints a standardized resource update message
func PrintSuccess ¶
PrintSuccess prints a success message with green color and a checkmark
func PrintWarning ¶
PrintWarning prints a warning message with yellow color
func StripANSIColors ¶
stripANSIColors removes ANSI color codes from a string
Types ¶
type OutputFields ¶
type OutputFields interface {
any
}
OutputFields is a marker interface for output-formattable types
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 resource tag key-value pair for output
type Spinner ¶ added in v0.4.0
type Spinner struct {
// contains filtered or unexported fields
}
Spinner represents a loading spinner with state
func NewSpinner ¶ added in v0.4.0
NewSpinner creates a new spinner instance
func PrintCustomSpinner ¶ added in v0.4.4
PrintCustomSpinner shows an animated spinner with a custom message
func PrintListingResourceTags ¶ added in v0.4.3
PrintListingResourceTags shows an animated spinner while listing resource tags
func PrintLoggingIn ¶ added in v0.4.3
PrintLoggingIn shows an animated spinner while logging in to Megaport
func PrintResourceCreating ¶ added in v0.4.0
PrintResourceCreating shows an animated spinner while a resource is being created
func PrintResourceDeleting ¶ added in v0.4.0
PrintResourceDeleting shows an animated spinner while a resource is being deleted
func PrintResourceGetting ¶ added in v0.4.0
PrintResourceGetting shows an animated spinner while getting a resource's details
func PrintResourceListing ¶ added in v0.4.0
PrintResourceListing shows an animated spinner while resources are being listed
func PrintResourceUpdating ¶ added in v0.4.0
PrintResourceUpdating shows an animated spinner while a resource is being updated
func PrintResourceValidating ¶ added in v0.4.3
PrintResourceValidating shows an animated spinner while validating a resource order
func (*Spinner) Stop ¶ added in v0.4.0
func (s *Spinner) Stop()
Stop halts the spinner animation and clears the line
func (*Spinner) StopWithSuccess ¶ added in v0.4.0
StopWithSuccess stops the spinner and shows a success message while preserving the context