utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package utils provides utility functions for INIQ

Index

Constants

View Source
const (
	// Basic colors
	ColorReset   = "\033[0m"
	ColorGray    = "\033[90m"
	ColorGreen   = "\033[32m"
	ColorYellow  = "\033[33m"
	ColorBlue    = "\033[34m"
	ColorRed     = "\033[31m"
	ColorCyan    = "\033[36m"
	ColorMagenta = "\033[35m"

	// Bright colors
	ColorBrightGreen  = "\033[92m"
	ColorBrightYellow = "\033[93m"
	ColorBrightBlue   = "\033[94m"
	ColorBrightRed    = "\033[91m"
	ColorBrightCyan   = "\033[96m"

	// Text styles
	ColorBold      = "\033[1m"
	ColorUnderline = "\033[4m"

	// Combined styles
	ColorHeaderBlue = "\033[1;34m" // Bold Blue
	ColorHeaderCyan = "\033[1;36m" // Bold Cyan
	ColorSuccess    = "\033[32m"   // Green
	ColorWarning    = "\033[33m"   // Yellow
	ColorError      = "\033[31m"   // Red
	ColorInfo       = "\033[34m"   // Blue
	ColorDebug      = "\033[36m"   // Cyan
	ColorListItem   = "\033[90m"   // Gray
)

Colors for terminal output

Variables

This section is empty.

Functions

func BackupFile

func BackupFile(filePath string, backupEnabled bool) (string, error)

BackupFile creates a backup of a file with a timestamp If the file doesn't exist, it returns nil without creating a backup Returns the path to the backup file if successful

func BoldText

func BoldText(text string) string

BoldText returns the text in bold

func ColorText

func ColorText(text string, colorCode string) string

ColorText wraps text with the specified color code and resets the color afterward

func ErrorText

func ErrorText(text string) string

ErrorText returns the text in error color (red)

func InfoText

func InfoText(text string) string

InfoText returns the text in info color (blue)

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal checks if the given file is a terminal

func PromptWithDefault

func PromptWithDefault(question string, defaultValue string) string

PromptWithDefault asks the user for input with a default value and returns the user's input or the default if the user just presses Enter.

func PromptYesNo

func PromptYesNo(question string, defaultValue bool) bool

PromptYesNo asks the user a yes/no question and returns true for yes, false for no. The defaultValue parameter determines the default answer if the user just presses Enter. After the user makes a choice, it displays what was selected.

func SuccessText

func SuccessText(text string) string

SuccessText returns the text in success color (green)

func WarningText

func WarningText(text string) string

WarningText returns the text in warning color (yellow)

Types

This section is empty.

Jump to

Keyboard shortcuts

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