diff --git a/helpers.go b/helpers.go index 8caaef4..3a3d9ce 100644 --- a/helpers.go +++ b/helpers.go @@ -214,11 +214,13 @@ func leftPadKey(k string) string { } var colors = struct { + reset func(...any) (int, error) italic func(...any) string italicf func(string, ...any) string bold func(...any) string boldf func(string, ...any) string }{ + color.New(color.Reset).Print, color.New(color.Italic).Sprint, color.New(color.Italic).Sprintf, color.New(color.Bold).Sprint, diff --git a/main.go b/main.go index e08b059..96d05c3 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "os" "path/filepath" - "github.com/fatih/color" "github.com/fiatjaf/cli/v3" "github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr/sdk" @@ -133,12 +132,16 @@ var app = &cli.Command{ } func main() { - defer func() { - color.New(color.Reset).Print() - }() + defer colors.reset() + + cli.VersionFlag = &cli.BoolFlag{ + Name: "version", + Usage: "prints the version", + } + if err := app.Run(context.Background(), os.Args); err != nil { stdout(err) - color.New(color.Reset).Print() + colors.reset() os.Exit(1) } }