76 lines
2.3 KiB
Go
76 lines
2.3 KiB
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// Цвета для терминала
|
|
const (
|
|
ColorReset = "\033[0m"
|
|
ColorBold = "\033[1m"
|
|
ColorDim = "\033[2m"
|
|
ColorCyan = "\033[36m"
|
|
ColorGreen = "\033[32m"
|
|
ColorYellow = "\033[33m"
|
|
ColorBlue = "\033[34m"
|
|
ColorMagenta = "\033[35m"
|
|
ColorRed = "\033[31m"
|
|
ColorWhite = "\033[97m"
|
|
BgBlue = "\033[44m"
|
|
BgGray = "\033[100m"
|
|
)
|
|
|
|
func Header(title string) {
|
|
width := 60
|
|
line := strings.Repeat("─", width)
|
|
padding := (width - len([]rune(title))) / 2
|
|
padStr := strings.Repeat(" ", padding)
|
|
fmt.Printf("\n%s%s┌%s┐%s\n", ColorBold, ColorCyan, line, ColorReset)
|
|
fmt.Printf("%s%s│%s%s%s%s%s│%s\n",
|
|
ColorBold, ColorCyan,
|
|
ColorReset, ColorBold, ColorWhite, padStr+title, ColorReset+ColorBold+ColorCyan,
|
|
ColorReset)
|
|
fmt.Printf("%s%s└%s┘%s\n\n", ColorBold, ColorCyan, line, ColorReset)
|
|
}
|
|
|
|
func Section(title string) {
|
|
fmt.Printf("\n%s%s▶ %s%s\n", ColorBold, ColorYellow, title, ColorReset)
|
|
fmt.Printf("%s%s%s\n", ColorDim, strings.Repeat("─", 50), ColorReset)
|
|
}
|
|
|
|
func Code(code string) {
|
|
lines := strings.Split(strings.TrimSpace(code), "\n")
|
|
fmt.Printf("%s%s ┌─ код ────────────────────────────────────%s\n", ColorDim, ColorBold, ColorReset)
|
|
for _, line := range lines {
|
|
fmt.Printf("%s%s │%s %s%s%s\n", ColorDim, ColorBold, ColorReset, ColorGreen, line, ColorReset)
|
|
}
|
|
fmt.Printf("%s%s └───────────────────────────────────────────%s\n", ColorDim, ColorBold, ColorReset)
|
|
}
|
|
|
|
func Command(cmd, description string) {
|
|
fmt.Printf(" %s%-40s%s %s%s%s\n",
|
|
ColorCyan+ColorBold, cmd, ColorReset,
|
|
ColorDim, description, ColorReset)
|
|
}
|
|
|
|
func Note(text string) {
|
|
fmt.Printf("\n %s%s💡 %s%s\n", ColorBold, ColorYellow, text, ColorReset)
|
|
}
|
|
|
|
func Info(label, value string) {
|
|
fmt.Printf(" %s%s%-20s%s %s\n", ColorBold, ColorMagenta, label+":", ColorReset, value)
|
|
}
|
|
|
|
func Println(text string) {
|
|
fmt.Printf(" %s\n", text)
|
|
}
|
|
|
|
func Separator() {
|
|
fmt.Printf("\n%s%s%s\n\n", ColorDim, strings.Repeat("═", 60), ColorReset)
|
|
}
|
|
|
|
func Footer() {
|
|
fmt.Printf("\n%s%s%s%s\n\n", ColorDim, ColorCyan,
|
|
strings.Repeat("─", 60), ColorReset)
|
|
}
|