futriis/pkg/utils/colors.go

84 lines
2.7 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// /futriis/pkg/utils/colors.go
// Пакет utils предоставляет вспомогательные функции для форматирования вывода
package utils
import (
"fmt"
"strings"
)
// Цветовые коды ANSI
const (
ColorReset = "\033[0m"
ColorRed = "\033[31m"
ColorGreen = "\033[32m"
ColorYellow = "\033[33m"
ColorBlue = "\033[34m"
ColorCyan = "\033[36m"
ColorPromptCode = "\033[38;5;39m" // Ярко-синий для приглашения
ColorDeepSkyBlue = "\033[38;2;0;191;255m" // #00bfff - Глубокий небесно-голубой
)
// GetPrompt возвращает строку приглашения с цветом
func GetPrompt() string {
return ColorPromptCode + "futriis:~> " + ColorReset
}
// PrintInfo выводит информационное сообщение
func PrintInfo(format string, args ...interface{}) {
fmt.Printf(ColorBlue+"[INFO] "+format+ColorReset+"\n", args...)
}
// PrintSuccess выводит сообщение об успехе
func PrintSuccess(format string, args ...interface{}) {
fmt.Printf(ColorGreen+"[OK] "+format+ColorReset+"\n", args...)
}
// PrintWarning выводит предупреждающее сообщение
func PrintWarning(format string, args ...interface{}) {
fmt.Printf(ColorYellow+"[WARNING] "+format+ColorReset+"\n", args...)
}
// PrintError выводит сообщение об ошибке
func PrintError(format string, args ...interface{}) {
fmt.Printf(ColorRed+"[ERROR] "+format+ColorReset+"\n", args...)
}
// PrintBanner выводит приветственный баннер при запуске
func PrintBanner() {
banner := `
F U T R I I S
Distributed Database System
`
// Верхняя граница цветом #00bfff
fmt.Print(ColorDeepSkyBlue + strings.Repeat("═", 35) + "\n" + ColorReset)
// Баннер построчно с выравниванием
lines := strings.Split(banner, "\n")
for _, line := range lines {
if line != "" {
// Центрируем текст
padding := (35 - len(line)) / 2
if padding < 0 {
padding = 0
}
// Левая граница цветом #00bfff
fmt.Print(ColorDeepSkyBlue + "║" + ColorReset + strings.Repeat(" ", padding))
// Логотип и описание тоже цветом #00bfff
fmt.Print(ColorDeepSkyBlue + line + ColorReset)
// Правая граница
fmt.Println(strings.Repeat(" ", 35-len(line)-padding) + ColorDeepSkyBlue + "║" + ColorReset)
}
}
// Нижняя граница цветом #00bfff
fmt.Print(ColorDeepSkyBlue + strings.Repeat("═", 35) + "\n" + ColorReset)
// Версия
fmt.Print(ColorDeepSkyBlue + "Версия 0.1.0\n\n" + ColorReset)
}