-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Normalize printing to Out vs. Err streams #1709
Conversation
Thanks @mislav. Cobra does have some inconsistencies about printing output. However Cobra being so widely used we have to prioritize backward-compatibility at the expense of standardizing things. If we ever decided to have a Cobra v2, we would surely standardize the output handling. But moving to a new major version had such a large impact to projects that I would personally prefer avoiding it. |
@marckhouzam Thanks for chiming in. And I understand if backwards compatibility is a priority, then it's not a good idea to merge this. Feel free to close; this changeset was mostly meant to complement the referenced issue. |
Thank you for taking the time @mislav. |
Another idea: taking an approach where backwards compatibility is kept, but introducing a new opt-in method that replaces So for example, we could publish a new method e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking myself for review.
I agree - there are some major inconsistencies across many of Cobra's APIs.
I'm unsure what to do; the number of things we'd like to fix that would be a breaking change in Cobra could have wide reaching impacts across kubernetes, enterprise software, GitHub, etc.
But these are improvements we should make. And the maintainers should to some degree feel empowered to make these changes.
TLDR: I'd like to do this. And I think it should exist in some new 2.0 of Cobra, I'm just unsure how to start moving towards that.
Thanks for taking the time to chime in. What is the most conservative change that the maintainers of Cobra would be willing to accept in order to fix the main bug in the referenced issue (deprecation warnings going to the "Out" stream)? I'm thinking something along these lines: avoid changing the functionality of |
The Cobra project currently lacks enough contributors to adequately respond to all PRs. This bot triages issues and PRs according to the following rules:
|
The Cobra project currently lacks enough contributors to adequately respond to all PRs. This bot triages issues and PRs according to the following rules:
|
I'm still interested, though the attached issue has lapsed. |
Per my previous comment, I'm still willing to do this:
But I'd like a confirmation from Cobra core team (or person) before I proceed, because I wouldn't like to continue doing work on this if it's going to just get closed by the stale bot (like the referenced issue I opened). My idea would be to trim down this PR to just bug fixes (e.g. deprecation notices go to "err" stream instead of "out" stream) but leave public APIs the same (i.e. |
The Cobra project currently lacks enough contributors to adequately respond to all PRs. This bot triages issues and PRs according to the following rules:
|
I'm interested as well. There is one specific task I'd like to perform in my app: adding unit tests to verify the output of stdout/stderr. |
The referenced issue got re-opened and in the meantime this PR got outdated, so I'm closing it in favor of the discussion in the issue. There still doesn't seem to be consensus in how this should be solved, so until there is, I don't think there needs to exist a PR that proposes code changes. |
Thanks for the contribution @mislav and apologies we couldn't get this in. Yes, let's continue the discussion in the issue. |
command.Print*()
print to stdout, and print errors & warnings to stderrcommand.OutOrStderr()
Warning: backwards-incompatible.
Fixes #1708