From 619efbdcebad273dd2c1a7ba39ba3db7b0446c04 Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Fri, 9 Feb 2024 16:46:29 +0100 Subject: [PATCH] better error messages --- cmd/main.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 3e2d482..1af81a6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -46,9 +46,10 @@ func main() { __load() root := &cobra.Command{ - Use: "dottie", - Short: "dottie pretty cool", - Version: buildVersion().String(), + Use: "dottie", + Short: "Simplify working with .env files", + SilenceErrors: true, + Version: buildVersion().String(), } root.AddCommand(disable.Command) @@ -64,8 +65,10 @@ func main() { root.PersistentFlags().String("file", ".env", "Load this file") - if err := root.Execute(); err != nil { - tui.Theme.Danger.StderrPrinter().Printfln("Error: %s", err) + if c, err := root.ExecuteC(); err != nil { + tui.Theme.Danger.StderrPrinter().Println(c.ErrPrefix(), err.Error()) + tui.Theme.Info.StderrPrinter().Printfln("Run '%v --help' for usage.\n", c.CommandPath()) + os.Exit(1) } }