utils

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatePercentage

func CalculatePercentage(used, total float64) float64

CalculatePercentage safely calculates percentage from used and total values Returns 0.0 if total is 0 to avoid division by zero.

func CalculatePercentageInt

func CalculatePercentageInt(used, total int64) float64

CalculatePercentageInt safely calculates percentage from used and total int64 values Returns 0.0 if total is 0 to avoid division by zero.

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats a byte count to a human-readable format with dynamic units Always shows 2 decimal places and chooses the most appropriate unit (GB, TB, PB).

func FormatBytesFloat

func FormatBytesFloat(gb float64) string

FormatBytesFloat converts float64 GB values to human-readable format Input is assumed to be in GB, converts to appropriate units with 2 decimal places.

func FormatPendingStatusIndicator

func FormatPendingStatusIndicator(status string, isPending bool, operation string) string

FormatPendingStatusIndicator returns a status indicator with pending state visual feedback. Shows a dimmed indicator with a pulsing effect for pending operations.

func FormatStatusIndicator

func FormatStatusIndicator(status string) string

FormatStatusIndicator returns a string with a colored status emoji. Uses theme-aware color tags.

func FormatUptime

func FormatUptime(uptime int) string

FormatUptime formats the uptime in seconds to a human-readable format.

func TrimTrailingWhitespace

func TrimTrailingWhitespace(s string) string

TrimTrailingWhitespace removes all trailing whitespace (spaces, tabs, newlines, carriage returns) from the end of the string.

func WaitForEnter

func WaitForEnter()

WaitForEnter waits for the user to press Enter before continuing. This is useful for pausing execution and waiting for user acknowledgment.

func WaitForEnterToReturn

func WaitForEnterToReturn(err error, successMsg, failureMsg string)

WaitForEnterToReturn displays a status message and waits for the user to press Enter before returning to the TUI. This provides a consistent experience across all suspend/resume operations.

func WaitForReturnWithCountdown

func WaitForReturnWithCountdown(seconds int)

WaitForReturnWithCountdown waits for a specified number of seconds, displaying a countdown, before returning to the TUI.

Types

This section is empty.

Jump to

Keyboard shortcuts

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