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

Write help text to stderr instead of stdout #1069

Closed
wants to merge 4 commits into from
Closed

Write help text to stderr instead of stdout #1069

wants to merge 4 commits into from

Conversation

cengizhanbasak
Copy link

Pull Request

#997

Problem

Informative functions were writing to stdout, causing problems in piping the output of the script.

Solution

Changed writing stdout to stderr.

ChangeLog

  • Changed stdout to stderr for informative outputs.

@shadowspawn
Copy link
Collaborator

There is a typo!

But changing over to stderr properly will require more work than this. When the help is explicitly asked for, the display should continue to go to stdout as now. It is only when the help is displayed due to an input error that it should go to stderr.

@cengizhanbasak
Copy link
Author

Added a parameter for outputHelp, allowing users to specify if they want to output to stderr or not. Output is to stderr as default, "--help" outputs to stdout though.

@shadowspawn
Copy link
Collaborator

shadowspawn commented Oct 4, 2019

The failing test is due to one change you made earlier which I think is not correct. I'll let you look into it.

Note 1: you can run the tests locally before you push.
Note 2: there have been big changes to the tests on the develop branch, which has the code for the next version of Commander.

I do not want to change the public interface for .outputHelp, but that is a reasonable place to experiment as it is a bottleneck for the current calls. You have added a parameter to .outputHelp, but everywhere it is called you are passing false so I don't think you have changed the error case.

I think getting the help-as-error to stderr in a tidy way is a tricky problem and harder than it looks. If you find the associated emit call, you will see a further complication...

@shadowspawn
Copy link
Collaborator

shadowspawn commented Oct 4, 2019

I added a question for original poster. I was thinking about the help-as-error case where user has no control, but that may not have been what the original poster was commenting on.

@shadowspawn
Copy link
Collaborator

Thanks @cengizhanbasak , I see both your original simple change and second try were consistent with what original poster was asking for. (I had a different case in mind.)

However, there is a work-around, and I don't think this change offers enough to justify the extra parameter to .outputHelp for now.

#997 is one person's issue and has not attracted any likes in a couple of months of being open, and this change would not resolve the couple of previous issues that have mentioned stderr. The help related functions are currently a somewhat odd collection of routines that have limited use. I would like a clearer idea of what changes will make them more widely useful and not make one-off additions.

Thank you for your contributions.

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

Successfully merging this pull request may close these issues.

2 participants