Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrintErrln & PrintErrf prints to stdout #1220

Closed
bukowa opened this issue Sep 8, 2020 · 1 comment
Closed

PrintErrln & PrintErrf prints to stdout #1220

bukowa opened this issue Sep 8, 2020 · 1 comment

Comments

@bukowa
Copy link

bukowa commented Sep 8, 2020

PrintErr prints to ErrOrStderr but PrintErrln and PrintErrf prints using Print which prints to OutOrStderr.

cobra/command.go

Lines 1190 to 1193 in 02a0d2f

// Print is a convenience method to Print to the defined output, fallback to Stderr if not set.
func (c *Command) Print(i ...interface{}) {
fmt.Fprint(c.OutOrStderr(), i...)
}

cobra/command.go

Lines 1205 to 1218 in 02a0d2f

// PrintErr is a convenience method to Print to the defined Err output, fallback to Stderr if not set.
func (c *Command) PrintErr(i ...interface{}) {
fmt.Fprint(c.ErrOrStderr(), i...)
}
// PrintErrln is a convenience method to Println to the defined Err output, fallback to Stderr if not set.
func (c *Command) PrintErrln(i ...interface{}) {
c.Print(fmt.Sprintln(i...))
}
// PrintErrf is a convenience method to Printf to the defined Err output, fallback to Stderr if not set.
func (c *Command) PrintErrf(format string, i ...interface{}) {
c.Print(fmt.Sprintf(format, i...))
}

Thats how it is now:

// PrintErrln is a convenience method to Print to the defined output, fallback to Stderr if not set. 
// PrintErrf is a convenience method to Print to the defined output, fallback to Stderr if not set. 
@marckhouzam
Copy link
Collaborator

Duplicate of #1100.
Possible fix at #894

@bukowa bukowa closed this as completed Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants