utils

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// RegionGlobePulseFrames controls how many spinner ticks pass before the marker changes intensity.
	RegionGlobePulseFrames = 8
)

Variables

View Source
var (
	LastPrintedString string
)

Functions

func CheckIfEmpty

func CheckIfEmpty(parameter string) error

func CheckIfNilOrEmpty

func CheckIfNilOrEmpty(parameter *string) bool

func ConfigureLogging

func ConfigureLogging(logLevel string, logFormat string)

func ConfigureLoggingFromEnvOnce

func ConfigureLoggingFromEnvOnce()

func ConfirmAction added in v0.14.18

func ConfirmAction(message string) (bool, error)

ConfirmAction displays a Yes/No confirmation prompt and returns true if the user selects Yes.

func CrashLogPath added in v1.2.16

func CrashLogPath() string

CrashLogPath returns the path to the crash log file.

func CutString

func CutString(str string, length int) string

func EnsureCursorRestoration added in v1.0.34

func EnsureCursorRestoration()

EnsureCursorRestoration forces cursor restoration - should be called in cleanup

func FormatJSON added in v0.14.18

func FormatJSON(data interface{}) (string, error)

FormatJSON formats an interface{} as pretty-printed JSON

func FromInt64Ptr

func FromInt64Ptr(val *int64) *int

FromInt64Ptr converts int64 pointer to int pointer

func FromPtr

func FromPtr[T any](ref *T) T

func FromPtrOrDefault

func FromPtrOrDefault[T any](ref *T, defaultVal T) T

func GetFirstDifferentSegmentInFilePaths

func GetFirstDifferentSegmentInFilePaths(targetPath string, comparisonPaths []string) string

GetFirstDifferentSegmentInFilePaths finds the first different segment between targetPath and each path in comparisonPaths. If no difference is found, it returns the last segment of targetPath.

func GetSupportedFilterKeys

func GetSupportedFilterKeys[T any](obj T) (supportedFilterKeys []string)

func HandlePanic added in v1.2.16

func HandlePanic()

HandlePanic should be deferred at the top of the program entry point. It recovers from panics, writes a crash log, restores the terminal, and exits.

func HandleSpinnerError

func HandleSpinnerError(spinner *Spinner, sm SpinnerManager, err error)

func HandleSpinnerSuccess

func HandleSpinnerSuccess(spinner *Spinner, sm SpinnerManager, message string)

func HashSha256 added in v0.14.27

func HashSha256(source string) (hash string)

HashSha256 returns the SHA256 hash of the given string. This is used to hash file contents or other strings for integrity checks. Not used for password hashing.

func MatchesFilters

func MatchesFilters[T any](obj T, filterMaps []map[string]string) (matches bool, err error)

func ParseCommaSeparatedList added in v0.14.18

func ParseCommaSeparatedList(input string) []string

ParseCommaSeparatedList parses a comma-separated string into a slice of strings

func ParseDeploymentTarget added in v1.6.8

func ParseDeploymentTarget(text string) (provider, region string, ok bool)

ParseDeploymentTarget extracts cloud provider and region from deploy progress text.

func ParseFilters

func ParseFilters(filters []string, supportedFilterKeys []string) (filterMaps []map[string]string, err error)

func PrintError

func PrintError(err error)

func PrintInfo

func PrintInfo(msg string)

func PrintJSON

func PrintJSON(res interface{})

func PrintSuccess

func PrintSuccess(msg string)

func PrintTable

func PrintTable(jsonData []string) (err error)

func PrintText

func PrintText(data []string) (err error)

func PrintTextTableJsonArrayOutput

func PrintTextTableJsonArrayOutput[T any](output string, objects []T) error

func PrintTextTableJsonOutput

func PrintTextTableJsonOutput[T any](output string, object T) error

func PrintTextTableYamlOutput added in v0.14.18

func PrintTextTableYamlOutput[T any](object T) error

func PrintURL

func PrintURL(label, url string)

func PrintWarning

func PrintWarning(msg string)

func PromptInput added in v1.2.7

func PromptInput(title, placeholder string, validate func(string) error) (string, error)

PromptInput displays a text input prompt with optional validation.

func PromptPassword added in v1.2.7

func PromptPassword(title, placeholder string) (string, error)

PromptPassword displays a masked password input prompt.

func PromptSelect added in v1.2.7

func PromptSelect(title string, options []string) (string, error)

PromptSelect displays a selection prompt and returns the chosen option.

func ReadFile added in v0.14.18

func ReadFile(filePath string) ([]byte, error)

ReadFile reads the contents of a file

func RenderRegionGlobe added in v1.6.8

func RenderRegionGlobe(region string, width int, blinkOn bool) string

RenderRegionGlobe renders a compact globe with a highlighted deployment region.

func RenderRegionGlobeWithProvider added in v1.6.8

func RenderRegionGlobeWithProvider(provider, region string, width int, blinkOn bool) string

RenderRegionGlobeWithProvider renders a compact globe with cloud provider and deployment region labels.

func ReplaceBuildContext

func ReplaceBuildContext(input string, dockerPathsToImageUrls map[string]string) string

func ToPtr

func ToPtr[T any](value T) *T

func TruncateString

func TruncateString(str string, num int) string

func ValidateEmail added in v1.2.7

func ValidateEmail(input string) error

ValidateEmail returns a validation function that checks for a valid email address.

func WriteYAMLToFile added in v0.14.18

func WriteYAMLToFile[T any](filePath string, object T) error

Types

type InteractiveListConfig added in v1.2.7

type InteractiveListConfig struct {
	Title    string
	Items    []InteractiveListItem
	OnSelect func(item InteractiveListItem) error
	ShowJSON bool
}

InteractiveListConfig configures the interactive list behavior.

type InteractiveListItem added in v1.2.7

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

InteractiveListItem represents a single item in the interactive list.

func NewInteractiveListItem added in v1.2.7

func NewInteractiveListItem(name, description, id, status string, rawJSON json.RawMessage) InteractiveListItem

NewInteractiveListItem creates a new list item from structured data.

func RunInteractiveList added in v1.2.7

func RunInteractiveList(cfg InteractiveListConfig) (*InteractiveListItem, error)

RunInteractiveList launches an interactive list TUI. Returns the selected item or nil if cancelled.

func (InteractiveListItem) Description added in v1.2.7

func (i InteractiveListItem) Description() string

func (InteractiveListItem) FilterValue added in v1.2.7

func (i InteractiveListItem) FilterValue() string

func (InteractiveListItem) ID added in v1.2.7

func (i InteractiveListItem) ID() string

func (InteractiveListItem) JSONData added in v1.2.7

func (i InteractiveListItem) JSONData() string

func (InteractiveListItem) Status added in v1.2.7

func (i InteractiveListItem) Status() string

func (InteractiveListItem) Title added in v1.2.7

func (i InteractiveListItem) Title() string

type Spinner added in v1.2.7

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

Spinner is a handle to a single spinner entry in a SpinnerManager.

func (*Spinner) Complete added in v1.2.7

func (s *Spinner) Complete()

Complete marks the spinner as successfully completed.

func (*Spinner) Error added in v1.2.7

func (s *Spinner) Error()

Error marks the spinner as failed.

func (*Spinner) UpdateMessage added in v1.2.7

func (s *Spinner) UpdateMessage(msg string)

UpdateMessage changes the spinner's display message.

type SpinnerManager added in v1.2.7

type SpinnerManager interface {
	AddSpinner(msg string) *Spinner
	Start()
	Stop()
	Running() bool
}

SpinnerManager manages one or more spinners rendered inline in the terminal.

func NewSpinnerManager added in v1.2.7

func NewSpinnerManager() SpinnerManager

NewSpinnerManager creates a new SpinnerManager backed by a bubbletea program.

type Table

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

Table wraps a bubbles table for rendering structured data.

func NewTable

func NewTable(columns []any) (t *Table)

func NewTableFromJSONTemplate

func NewTableFromJSONTemplate(data json.RawMessage) (t *Table, err error)

func (*Table) AddRow

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

func (*Table) AddRowFromJSON

func (t *Table) AddRowFromJSON(data json.RawMessage) error

func (Table) Print

func (t Table) Print()

func (Table) PrintToWriter

func (t Table) PrintToWriter(w io.Writer)

Jump to

Keyboard shortcuts

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