Skip to content

Commit

Permalink
better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jippi committed Feb 9, 2024
1 parent 905280e commit 619efbd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}
Expand Down

0 comments on commit 619efbd

Please sign in to comment.