2023-01-09 23:48:19 +01:00
|
|
|
package tui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2023-01-13 20:36:07 +01:00
|
|
|
var SeriousBusiness = lipgloss.NewStyle().Foreground(lipgloss.Color("#D90166"))
|
|
|
|
var ErrorLabel = SeriousBusiness.Render("ERROR")
|
|
|
|
var Attention = lipgloss.NewStyle().Foreground(lipgloss.Color("#FFA500"))
|
|
|
|
var WarningLabel = Attention.Render("WARNING")
|
|
|
|
var Code = lipgloss.NewStyle().Foreground(lipgloss.Color("#00FFFF"))
|
2023-01-09 23:48:19 +01:00
|
|
|
|
|
|
|
func Error(msg string, err error) {
|
|
|
|
if err != nil {
|
2023-01-09 23:56:16 +01:00
|
|
|
_, _ = fmt.Fprintf(os.Stderr, "[%v]: %v (%v)\n", ErrorLabel, msg, strings.TrimSpace(err.Error()))
|
2023-01-09 23:48:19 +01:00
|
|
|
} else {
|
2023-01-09 23:56:16 +01:00
|
|
|
_, _ = fmt.Fprintf(os.Stderr, "[%v] %v\n", ErrorLabel, msg)
|
2023-01-09 23:48:19 +01:00
|
|
|
}
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Warning(msg string, v ...interface{}) {
|
2023-01-09 23:51:41 +01:00
|
|
|
_, _ = fmt.Fprintf(os.Stderr, "%v: "+msg+"\n", append([]interface{}{WarningLabel}, v...))
|
2023-01-09 23:48:19 +01:00
|
|
|
}
|