From e2dd3ca544d1420543f49752a6da5eb8dcc578e5 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 30 Jan 2025 19:58:17 -0300 Subject: [PATCH] fix -v verbose flag (it was being used by the default --version flag). --- helpers.go | 2 ++ main.go | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) 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) } }