-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
Apologies if my implementation is busted but if I do the following:
var rootCmd = &cobra.Command{
Use: "root",
Run: func(cmd *cobra.Command, args []string) {
cmd.Println("PRINT 1")
cmd.PrintErrln("PRINTERR 1")
cmd.SetOut(os.Stdout)
cmd.SetErr(os.Stderr)
cmd.Println("PRINT 2")
cmd.PrintErrln("PRINTERR 2")
},
}
I see this behaviour:
13:57:20 ▶ root
PRINT 1
PRINTERR 1
PRINT 2
PRINTERR 2
13:57:29 ▶ root > /dev/null
PRINT 1
PRINTERR 1
13:57:33 ▶ root 2> /dev/null
PRINT 2
PRINTERR 2
I know cmd.Println
sends to stderr by default, so I expect ^this to look more like this maybe:
13:57:20 ▶ root
PRINT 1
PRINTERR 1
PRINT 2
PRINTERR 2
13:57:29 ▶ root > /dev/null
PRINT 1
PRINTERR 1
PRINTERR 2
13:57:33 ▶ root 2> /dev/null
PRINT 2
Am I using the Set
functions incorrectly or is this a bug?
Metadata
Metadata
Assignees
Labels
No labels