util

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorText

func ColorText(text, colorName string) string

ColorText applies color formatting to text based on the color name

func Contains

func Contains(slice []string, item string) bool

Contains checks if a string slice contains a specific item

func FilterContainersByRestrict

func FilterContainersByRestrict(containers []string, restrict string) ([]string, error)

FilterContainersByRestrict filters a list of containers by a regex pattern

func FormatDuration

func FormatDuration(timestamp string) string

FormatDuration converts a Kubernetes timestamp to a human-readable duration

func GetDisplayWidth

func GetDisplayWidth(s string) int

GetDisplayWidth calculates the actual display width of a string

func IsBashShell

func IsBashShell(shell string) bool

IsBashShell checks if the shell path looks like bash

func PadToWidth

func PadToWidth(s string, width int) string

PadToWidth pads a string to a specific display width

func ResourceName added in v1.2.0

func ResourceName(value string) string

ResourceName returns the name portion from a resource/name string.

func StripANSI

func StripANSI(s string) string

StripANSI removes ANSI color codes from a string to get actual display width

func TerminalWidth added in v1.2.0

func TerminalWidth() int

TerminalWidth returns the current terminal width or a sensible default.

func Which

func Which(program string) string

Which finds the full path of an executable in PATH

Types

type RealRunner added in v1.2.0

type RealRunner struct{}

RealRunner implementation using os/exec.

func (*RealRunner) Run added in v1.2.0

func (r *RealRunner) Run(name string, args ...string) ([]byte, error)

Run executes a command and returns its combined output.

type Runner added in v1.2.0

type Runner interface {
	Run(name string, args ...string) ([]byte, error)
}

Runner defines the interface for running commands.

Jump to

Keyboard shortcuts

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