utils

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Colors = map[string]string{
	"red":            "\033[31m",
	"green":          "\033[32m",
	"yellow":         "\033[33m",
	"blue":           "\033[34m",
	"purple":         "\033[35m",
	"cyan":           "\033[36m",
	"white":          "\033[37m",
	"black":          "\033[30m",
	"grey":           "\033[90m",
	"brightRed":      "\033[91m",
	"brightGreen":    "\033[92m",
	"brightYellow":   "\033[93m",
	"brightBlue":     "\033[94m",
	"brightPurple":   "\033[95m",
	"brightCyan":     "\033[96m",
	"brightWhite":    "\033[97m",
	"darkRed":        "\033[38;5;124m",
	"darkGreen":      "\033[38;5;28m",
	"darkYellow":     "\033[38;5;214m",
	"darkBlue":       "\033[38;5;32m",
	"darkPurple":     "\033[38;5;93m",
	"darkCyan":       "\033[38;5;39m",
	"darkWhite":      "\033[38;5;255m",
	"bgRed":          "\033[41m",
	"bgGreen":        "\033[42m",
	"bgYellow":       "\033[43m",
	"bgBlue":         "\033[44m",
	"bgPurple":       "\033[45m",
	"bgCyan":         "\033[46m",
	"bgWhite":        "\033[47m",
	"bgBlack":        "\033[40m",
	"bgGrey":         "\033[100m",
	"bgBrightRed":    "\033[101m",
	"bgBrightGreen":  "\033[102m",
	"bgBrightYellow": "\033[103m",
	"bgBrightBlue":   "\033[104m",
	"bgBrightPurple": "\033[105m",
	"bgBrightCyan":   "\033[106m",
	"bgBrightWhite":  "\033[107m",
	"bold":           "\033[1m",
	"dim":            "\033[2m",
	"italic":         "\033[3m",
	"underline":      "\033[4m",
	"blink":          "\033[5m",
	"reset":          "\033[0m",
	"teal":           "\033[38;5;37m",
	"orange":         "\033[38;5;208m",
	"pink":           "\033[38;5;200m",
	"brown":          "\033[38;5;130m",
	"lightBlue":      "\033[38;5;153m",
	"lightGreen":     "\033[38;5;82m",
	"lightYellow":    "\033[38;5;226m",
	"lightPurple":    "\033[38;5;129m",
	"lightCyan":      "\033[38;5;87m",
	"lightWhite":     "\033[38;5;255m",
	"lightGrey":      "\033[38;5;245m",
	"lightBlack":     "\033[38;5;235m",
	"lightRed":       "\033[38;5;196m",
	"lightMagenta":   "\033[38;5;201m",
	"lightOrange":    "\033[38;5;214m",
	"lightPink":      "\033[38;5;213m",
	"lightBrown":     "\033[38;5;130m",
	"lightTeal":      "\033[38;5;37m",
	"lightTurquoise": "\033[38;5;51m",
	"lightViolet":    "\033[38;5;93m",
	"lightCoral":     "\033[38;5;196m",
	"lightSalmon":    "\033[38;5;210m",
	"lightLavender":  "\033[38;5;189m",
	"lightMint":      "\033[38;5;121m",
	"lightPeach":     "\033[38;5;214m",
	"lightLime":      "\033[38;5;190m",
	"lightOlive":     "\033[38;5;178m",
	"lightPlum":      "\033[38;5;129m",
	"lightSlate":     "\033[38;5;240m",
	"lightSteel":     "\033[38;5;246m",
	"lightSea":       "\033[38;5;44m",
	"lightSky":       "\033[38;5;153m",
	"pass":           "✓",
	"fail":           "✗",
}

Functions

func Colorize

func Colorize(msg string, color string) string

func DebugMessage

func DebugMessage(msg string) string

func DetailMessage

func DetailMessage(msg string) string

func ErrorMessage

func ErrorMessage(msg string) string

func FormatTitle

func FormatTitle(title string, width int, color string) string

Creates a title with formatting

func InfoMessage

func InfoMessage(msg string) string

func PrintProgress

func PrintProgress(current, total int, width int, color string) string

Prints a simple progress bar

func SliceSame

func SliceSame(slice1, slice2 []any) bool

SliceSame checks if two slices are same, but is not order-sensitive

func SuccessMessage

func SuccessMessage(msg string) string

Formatting messages

func WarningMessage

func WarningMessage(msg string) string

Types

type Dictionary

type Dictionary map[string]any

func (Dictionary) UnwindBool

func (d Dictionary) UnwindBool(keys ...string) bool

func (Dictionary) UnwindFloat32

func (d Dictionary) UnwindFloat32(keys ...string) float32

func (Dictionary) UnwindFloat64

func (d Dictionary) UnwindFloat64(keys ...string) float64

func (Dictionary) UnwindInt

func (d Dictionary) UnwindInt(keys ...string) int

func (Dictionary) UnwindInt32

func (d Dictionary) UnwindInt32(keys ...string) int32

func (Dictionary) UnwindInt64

func (d Dictionary) UnwindInt64(keys ...string) int64

func (Dictionary) UnwindMap

func (d Dictionary) UnwindMap(keys ...string) Dictionary

func (Dictionary) UnwindSlice

func (d Dictionary) UnwindSlice(keys ...string) []any

func (Dictionary) UnwindString

func (d Dictionary) UnwindString(keys ...string) string

func (Dictionary) UnwindUint

func (d Dictionary) UnwindUint(keys ...string) uint

func (Dictionary) UnwindUint64

func (d Dictionary) UnwindUint64(keys ...string) uint64

func (Dictionary) UnwindValue

func (d Dictionary) UnwindValue(keys ...string) any

UnwindValue safely navigates and retrieves values from nested maps

type FunctionOutput

type FunctionOutput struct {
	Name        string
	Status      string
	Message     string
	StreamLines []string
	Complete    bool
	StartTime   time.Time
	LastUpdated time.Time
}

type Manager

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

Output manager

func NewManager

func NewManager(maxStreams int) *Manager

Creates a new output manager

func (*Manager) AddStreamLine

func (m *Manager) AddStreamLine(name, line string)

Adds a single line to a function's stream output

func (*Manager) ClearAll added in v0.6.7

func (m *Manager) ClearAll()

Clear all function outputs

func (*Manager) ClearFunction

func (m *Manager) ClearFunction(name string)

Clears the output of a specific function

func (*Manager) ClearLines

func (m *Manager) ClearLines(n int)

Clears 'n' previous lines

func (*Manager) ClearOutput

func (m *Manager) ClearOutput()

Clear the entire screen

func (*Manager) Complete

func (m *Manager) Complete(name string)

Marks a function as complete

func (*Manager) DisplayTable

func (m *Manager) DisplayTable(name string, innerDividers bool)

Displays a specific table

func (*Manager) GetStatus

func (m *Manager) GetStatus(name string) string

Retrieves the status of a function

func (*Manager) GetStatusDisplay

func (m *Manager) GetStatusDisplay(status string) string

Returns a colored status indicator based on status

func (*Manager) GetTable

func (m *Manager) GetTable(name string) *Table

Retrieves a table by name

func (*Manager) Pause

func (m *Manager) Pause()

Pause the display updates

func (*Manager) Register

func (m *Manager) Register(name string)

Adds a new function to be tracked

func (*Manager) RegisterTable

func (m *Manager) RegisterTable(name string, headers []string) *Table

Adds a table to the manager

func (*Manager) Remove

func (m *Manager) Remove(name string)

Removes a function from the manager

func (*Manager) RemoveCompleted

func (m *Manager) RemoveCompleted()

Removes completed functions from the manager

func (*Manager) RemoveTable

func (m *Manager) RemoveTable(name string)

Removes a table from the manager

func (*Manager) ReportError

func (m *Manager) ReportError(name string, err error)

Sets a function's status to error

func (*Manager) Resume

func (m *Manager) Resume()

Resume the display updates

func (*Manager) SetMessage

func (m *Manager) SetMessage(name, message string)

Sets the primary message for a function

func (*Manager) SetStatus

func (m *Manager) SetStatus(name, status string)

Updates the status of a function

func (*Manager) SetUnlimitedOutput

func (m *Manager) SetUnlimitedOutput(unlimited bool)

Set whether output should be unlimited

func (*Manager) SetUpdateInterval

func (m *Manager) SetUpdateInterval(interval time.Duration)

Sets the interval between display updates

func (*Manager) ShowSummary

func (m *Manager) ShowSummary()

Displays a final summary of all functions

func (*Manager) StartDisplay

func (m *Manager) StartDisplay()

Starts the automatic display update goroutine

func (*Manager) StopDisplay

func (m *Manager) StopDisplay()

Stops the automatic display updates

func (*Manager) UpdateStreamOutput

func (m *Manager) UpdateStreamOutput(name string, output []string)

Adds lines to a function's stream output

type Table

type Table struct {
	Headers []string
	Rows    [][]string
}

func NewTable

func NewTable(headers []string) *Table

func (*Table) AddRow

func (t *Table) AddRow(row []string)

func (*Table) FormatMarkdownTable

func (t *Table) FormatMarkdownTable() string

func (*Table) FormatTable

func (t *Table) FormatTable(innerDividers bool) string

func (*Table) PrintMarkdownTable

func (t *Table) PrintMarkdownTable()

func (*Table) PrintTable

func (t *Table) PrintTable(innerDividers bool)

func (*Table) WriteMarkdownTableToFile

func (t *Table) WriteMarkdownTableToFile(outputPath string) error

Jump to

Keyboard shortcuts

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