util

package
v2.4.12 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: Apache-2.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Theme = func() *huh.Theme {
		t := huh.ThemeBase16()
		t.Focused.FocusedButton = t.Focused.FocusedButton.Foreground(lipgloss.Color("7")).Background(lipgloss.Color("4"))
		t.Focused.TextInput.Cursor.Foreground(lipgloss.Color("4"))
		return t
	}()

	Accented = func(text string) string {
		return Theme.Focused.Title.Render(text)
	}
	Dimmed = func(text string) string {
		return Theme.Focused.Description.Render(text)
	}

	Fg              = lipgloss.AdaptiveColor{Light: "235", Dark: "252"}
	FormBaseStyle   = Theme.Form.Base.Foreground(Fg).Padding(0, 1)
	FormHeaderStyle = FormBaseStyle.Bold(true)
)

Functions

func Await added in v2.4.9

func Await(title string, action func()) error

Call an action and show a spinner while waiting for it to finish.

func CopyFile

func CopyFile(src, dest string) error

Safely copy a file across filesystems, preserving permissions

func CreateTable

func CreateTable() *table.Table

func EllipsizeTo

func EllipsizeTo(str string, maxLength int) string

func ExtractSubdomain added in v2.4.6

func ExtractSubdomain(url string) string

func HashString

func HashString(str string) (string, error)

func MapStrings

func MapStrings(strs []string, fn func(string) string) []string

func MoveDir

func MoveDir(src, dest string) error

Safely move a directory across filesystems, preserving permissions

func PrintJSON

func PrintJSON(obj any)

func URLSafeName

func URLSafeName(projectURL string) (string, error)

func UseTempPath

func UseTempPath(permanentPath string) (string, func() error, func() error)

Provides a temporary path, a function to relocate it to a permanent path, and a function to clean up the temporary path that should always be deferred in the case of a failure to relocate.

func WrapToLines

func WrapToLines(input string, maxLineLength int) []string

func WrapWith

func WrapWith(wrap string) func(string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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