From e67ea3da4aca076fe18a41c4ac7724200fa11a3c Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Mon, 19 Oct 2020 15:09:24 +0200 Subject: [PATCH] fix: Exit program with error code on error --- nsd/cmd/root.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/nsd/cmd/root.go b/nsd/cmd/root.go index 6d0cca5..622d312 100644 --- a/nsd/cmd/root.go +++ b/nsd/cmd/root.go @@ -1,16 +1,24 @@ package cmd import ( + "os" + "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ - Use: "nsd", - Short: "A simple cli downloader for nodejs, npm and yarn", - Long: "", + Use: "nsd", + Short: "A simple cli downloader for nodejs, npm and yarn", + Long: "", + SilenceUsage: true, } // Execute executes the root command. func Execute() error { - return rootCmd.Execute() + if err := rootCmd.Execute(); err != nil { + os.Exit(1) + return err + } + + return nil }