package main

import (
	"fmt"
	"os"

	"github.com/spf13/viper"

	"github.com/minamijoyo/myaws/cmd"
)

func main() {
	if err := cmd.RootCmd.Execute(); err != nil {
		if viper.GetBool("debug") {
			fmt.Fprintf(os.Stderr, "%+v\n", err)
		} else {
			fmt.Fprintf(os.Stderr, "%v\n", err)
		}
		os.Exit(1)
	}
}

package main

import (
	"fmt"
	"os"

	"github.com/spf13/viper"

	"github.com/minamijoyo/myaws/cmd"
)

func main() {
	if err := cmd.RootCmd.Execute(); err != nil {
		if viper.GetBool("debug") {
			fmt.Printf("%+v\n", err)
		} else {
			fmt.Printf("%v\n", err)
		}
		os.Exit(1)
	}
}

--- 
+++ 
@@ -12,9 +12,9 @@
 func main() {
 	if err := cmd.RootCmd.Execute(); err != nil {
 		if viper.GetBool("debug") {
-			fmt.Printf("%+v\n", err)
+			fmt.Fprintf(os.Stderr, "%+v\n", err)
 		} else {
-			fmt.Printf("%v\n", err)
+			fmt.Fprintf(os.Stderr, "%v\n", err)
 		}
 		os.Exit(1)
 	}
Write error messages to stderr instead of stdout
