Skip to content

Commit

Permalink
set default output through cobra to stdout instead stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianrudnik committed Apr 25, 2020
1 parent d596281 commit f903164
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var Version = "1.0.0"
var NoTrailingNewlineFlag bool

func Execute() {
rootCmd.SetOutput(os.Stdout)

if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down Expand Up @@ -77,6 +79,7 @@ func init() {

func output(cmd *cobra.Command, val string) {
if !NoTrailingNewlineFlag {
cmd.OutOrStdout()
cmd.Println(val)
} else {
cmd.Printf("%s", val)
Expand Down

0 comments on commit f903164

Please sign in to comment.