util

package
v2.12.9 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MeetURL = "https://meet.livekit.io/custom"
)

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)
)
View Source
var (
	OpenFlag = &cli.StringFlag{
		Name:  "open",
		Usage: fmt.Sprintf("Open relevant `APP` in browser, supported options: %v", options),
		Validator: func(input string) error {
			if !slices.Contains(options, input) {
				return fmt.Errorf("invalid open target: %s, supported options: %v", input, options)
			}
			return nil
		},
	}
)

Functions

func Await added in v2.4.9

func Await(title string, ctx context.Context, action func(ctx context.Context) error) 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 ExpandTemplate added in v2.4.13

func ExpandTemplate(template string) string

func ExtractSubdomain added in v2.4.6

func ExtractSubdomain(url string) string

func FileExists added in v2.5.0

func FileExists(dir fs.FS, filename string) bool

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 OpenInMeet added in v2.4.13

func OpenInMeet(livekitURL, token string) error

func PrintJSON

func PrintJSON(obj any)

func ToUnixPath added in v2.5.2

func ToUnixPath(p string) string

Converts a path (possibly Windows-style) to a Unix-style path.

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

type OpenTarget added in v2.4.13

type OpenTarget string
const (
	OpenTargetMeet OpenTarget = "meet"
)

Jump to

Keyboard shortcuts

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