output

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func CaptureOutputErr(f func() error) (string, error)

captureOutputErr is a helper function to capture stdout output and return any error

func FormatCommandName

func FormatCommandName(name string, noColor bool) string

FormatCommandName colorizes command names

func FormatConfirmation

func FormatConfirmation(msg string, noColor bool) string

FormatConfirmation returns a formatted confirmation prompt

func FormatExample

func FormatExample(example string, noColor bool) string

FormatExample colorizes command examples in help text

func FormatJSONExample

func FormatJSONExample(json string, noColor bool) string

FormatJSONExample formats JSON examples in help text

func FormatNewValue added in v0.3.4

func FormatNewValue(value string, noColor bool) string

func FormatOldValue added in v0.3.4

func FormatOldValue(value string, noColor bool) string

Helper functions to format old and new values

func FormatOptionalFlag

func FormatOptionalFlag(flag string, description string, noColor bool) string

FormatOptionalFlag formats optional flags in help text

func FormatPrompt

func FormatPrompt(msg string, noColor bool) string

FormatPrompt returns a formatted input prompt

func FormatRequiredFlag

func FormatRequiredFlag(flag string, description string, noColor bool) string

FormatRequiredFlag highlights required flags in help text

func FormatSuccess

func FormatSuccess(msg string, noColor bool) string

FormatSuccess returns a formatted success string

func FormatUID

func FormatUID(uid string, noColor bool) string

func PrintError

func PrintError(format string, noColor bool, args ...interface{})

PrintError prints an error message with red color

func PrintInfo

func PrintInfo(format string, noColor bool, args ...interface{})

PrintInfo prints an info message with blue color

func PrintOutput

func PrintOutput[T OutputFields](data []T, format string, noColor bool) error

PrintOutput formats data in the specified output style

func PrintResourceCreated

func PrintResourceCreated(resourceType, uid string, noColor bool)

PrintResourceCreated prints a standardized resource creation message

func PrintResourceDeleted

func PrintResourceDeleted(resourceType, uid string, immediate, noColor bool)

PrintResourceDeleted prints a standardized resource deletion message

func PrintResourceSuccess

func PrintResourceSuccess(resourceType, action, uid string, noColor bool)

PrintResourceSuccess prints a success message for a resource operation

func PrintResourceUpdated

func PrintResourceUpdated(resourceType, uid string, noColor bool)

PrintResourceUpdated prints a standardized resource update message

func PrintSuccess

func PrintSuccess(format string, noColor bool, args ...interface{})

PrintSuccess prints a success message with green color and a checkmark

func PrintWarning

func PrintWarning(format string, noColor bool, args ...interface{})

PrintWarning prints a warning message with yellow color

func StripANSIColors

func StripANSIColors(s string) string

stripANSIColors removes ANSI color codes from a string

Types

type Output

type Output interface {
	// contains filtered or unexported methods
}

type OutputFields

type OutputFields interface {
	any
}

OutputFields is a marker interface for output-formattable types

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

func NewSpinner(noColor bool) *Spinner

NewSpinner creates a new spinner instance

func PrintResourceCreating added in v0.4.0

func PrintResourceCreating(resourceType, uid string, noColor bool) *Spinner

PrintResourceCreating shows an animated spinner while a resource is being created

func PrintResourceDeleting added in v0.4.0

func PrintResourceDeleting(resourceType, uid string, noColor bool) *Spinner

PrintResourceDeleting shows an animated spinner while a resource is being deleted

func PrintResourceGetting added in v0.4.0

func PrintResourceGetting(resourceType, uid string, noColor bool) *Spinner

PrintResourceGetting shows an animated spinner while getting a resource's details

func PrintResourceListing added in v0.4.0

func PrintResourceListing(resourceType string, noColor bool) *Spinner

PrintResourceListing shows an animated spinner while resources are being listed

func PrintResourceUpdating added in v0.4.0

func PrintResourceUpdating(resourceType, uid string, noColor bool) *Spinner

PrintResourceUpdating shows an animated spinner while a resource is being updated

func (*Spinner) Start added in v0.4.0

func (s *Spinner) Start(prefix string)

Start begins the spinner animation

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

func (s *Spinner) StopWithSuccess(msg string)

StopWithSuccess stops the spinner and shows a success message

Jump to

Keyboard shortcuts

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