Skip to content

Commit

Permalink
Only print out the error once (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydhulia authored Apr 3, 2021
1 parent 95a144c commit 80b9933
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ func Run(initFunctions ...func()) {
Execute()
}

func Execute() {
func Execute() error {
shutdown = make(chan os.Signal, 1)
done = make(chan int, 1)
signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)

if err := rootCmd.Execute(); err != nil {
rootCmd.PrintErr(err)
// err is already printed out by cobra's Execute
return err
}
return nil
}

func initConfig() {
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
package main

import (
"os"

"github.com/netflix/weep/cmd"
)

func main() {
cmd.Execute()
err := cmd.Execute()
if err != nil {
// err printing is handled by cobra
os.Exit(1)
}
}

0 comments on commit 80b9933

Please sign in to comment.