util

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorReset  = "\033[0m"
	ColorRed    = "\033[31m"
	ColorGreen  = "\033[32m"
	ColorYellow = "\033[33m"
	ColorBlue   = "\033[34m"
	ColorPurple = "\033[35m"
	ColorCyan   = "\033[36m"
	ColorWhite  = "\033[37m"
	ColorGray   = "\033[90m"
	ColorBold   = "\033[1m"

	ColorBoldRed    = "\033[1;31m"
	ColorBoldGreen  = "\033[1;32m"
	ColorBoldYellow = "\033[1;33m"
	ColorBoldBlue   = "\033[1;34m"
	ColorBoldPurple = "\033[1;35m"
	ColorBoldCyan   = "\033[1;36m"
	ColorBoldWhite  = "\033[1;37m"
)

ANSI color codes

Variables

View Source
var (
	// NoColor disables color output
	NoColor = os.Getenv("NO_COLOR") != ""
)

Functions

func Blue

func Blue(text string) string

Blue returns text in blue

func Bold

func Bold(text string) string

Bold returns text in bold

func Colorize

func Colorize(color, text string) string

Colorize wraps text in ANSI color codes

func Confirm

func Confirm(question string) (bool, error)

Confirm prompts the user for yes/no confirmation

func ConfirmWithDefault

func ConfirmWithDefault(question string, defaultValue bool) (bool, error)

ConfirmWithDefault prompts the user for yes/no with a default

func CopyDir

func CopyDir(src, dst string) error

CopyDir recursively copies a directory

func CreateDir

func CreateDir(path string) error

CreateDir creates a directory if it doesn't exist

func CreateFile

func CreateFile(path, content string) error

CreateFile creates a file with content

func Cyan

func Cyan(text string) string

Cyan returns text in cyan

func DirExists

func DirExists(path string) bool

DirExists checks if a directory exists

func Error

func Error(msg string)

Error prints an error message

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists

func GetProjectRoot

func GetProjectRoot() (string, error)

GetProjectRoot finds the project root by looking for go.mod

func Gray

func Gray(text string) string

Gray returns text in gray

func Green

func Green(text string) string

Green returns text in green

func Info

func Info(msg string)

Info prints an info message

func IsForgeUIProject

func IsForgeUIProject(dir string) bool

IsForgeUIProject checks if the directory is a ForgeUI project

func IsGoProject

func IsGoProject(dir string) bool

IsGoProject checks if the directory is a Go project

func Prompt

func Prompt(question string) (string, error)

Prompt prompts the user for input

func PromptWithDefault

func PromptWithDefault(question, defaultValue string) (string, error)

PromptWithDefault prompts the user for input with a default value

func Purple

func Purple(text string) string

Purple returns text in purple

func ReadLine

func ReadLine() (string, error)

ReadLine reads a line from the prompt reader

func Red

func Red(text string) string

Red returns text in red

func Select

func Select(question string, options []string) (int, error)

Select prompts the user to select from a list of options

func SelectWithDefault

func SelectWithDefault(question string, options []string, defaultIndex int) (int, error)

SelectWithDefault prompts the user to select from a list with a default

func Spin

func Spin(message string, fn func() error) error

Spin runs a function with a spinner

func SpinWithMessage

func SpinWithMessage(message, successMsg string, fn func() error) error

SpinWithMessage runs a function with a spinner and custom success message

func Success

func Success(msg string)

Success prints a success message

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase converts a string to camelCase

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase converts a string to PascalCase

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase converts a string to snake_case

func ValidateGoModule

func ValidateGoModule(module string) error

ValidateGoModule validates a Go module path

func ValidateProjectName

func ValidateProjectName(name string) error

ValidateProjectName validates a project name

func Warning

func Warning(msg string)

Warning prints a warning message

func Yellow

func Yellow(text string) string

Yellow returns text in yellow

Types

type PromptReader

type PromptReader interface {
	ReadString(delim byte) (string, error)
}

PromptReader is an interface for reading user input (for testing)

type Spinner

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

Spinner provides a simple loading spinner

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new spinner with a message

func (*Spinner) Error

func (s *Spinner) Error(msg string)

Error stops the spinner and shows an error message

func (*Spinner) Start

func (s *Spinner) Start()

Start starts the spinner animation

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop stops the spinner animation

func (*Spinner) Success

func (s *Spinner) Success(msg string)

Success stops the spinner and shows a success message

func (*Spinner) UpdateMessage

func (s *Spinner) UpdateMessage(msg string)

UpdateMessage updates the spinner message

func (*Spinner) WithDelay

func (s *Spinner) WithDelay(delay time.Duration) *Spinner

WithDelay sets the animation delay

func (*Spinner) WithFrames

func (s *Spinner) WithFrames(frames []string) *Spinner

WithFrames sets custom spinner frames

func (*Spinner) WithWriter

func (s *Spinner) WithWriter(w io.Writer) *Spinner

WithWriter sets the output writer

Jump to

Keyboard shortcuts

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