From 6204d8cffce846645d296dbf1fa145d48e3573a7 Mon Sep 17 00:00:00 2001 From: mahdi Date: Thu, 9 Nov 2023 00:02:27 +0100 Subject: [PATCH] echo - add Error func --- echo/echo.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/echo/echo.go b/echo/echo.go index 5c9865b..543418c 100644 --- a/echo/echo.go +++ b/echo/echo.go @@ -2,6 +2,7 @@ package echo import ( "fmt" + "os" "strings" "gitea.meta-tech.academy/go/core/style" @@ -79,6 +80,16 @@ func LineUp(count int) { fmt.Printf("\033[%dA", count) } +func Error(msg string, exit ...bool) { + fmt.Printf(" ") + Cstyle("ko").Echof(" %s ", msg) + Ln() + Ln() + if len(exit) > 0 && exit[0] { + os.Exit(1) + } +} + func GetArg(msg string) string { return Cstyle("usageArg").Applyf(" % s", msg) }