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

Should --help text be consistently written to stdout? #689

Open
varungandhi-src opened this issue Feb 1, 2022 · 3 comments
Open

Should --help text be consistently written to stdout? #689

varungandhi-src opened this issue Feb 1, 2022 · 3 comments
Labels

Comments

@varungandhi-src
Copy link
Contributor

For src CLI, it looks like help text with --help is output to either stderr or a mix of stdout and stderr.

For example, src --help seems to output everything to stderr. src lsif upload --help seems to output some text to stdout and some to stderr.

In either case, you need an extra 2&>1 if you want to pipe the output to a pager. My understanding is outputting help text to stderr is intentionally the default behavior for the flag package. (golang/go#17284, https://cs.opensource.google/go/go/+/refs/tags/go1.17.5:src/flag/flag.go;l=369;drc=refs%2Ftags%2Fgo1.17.5)

Since src is likely to be used by more non-Go developers compared to Go developers, would it make sense to consistently output the help text to stdout instead?

@chrispine
Copy link
Contributor

@varungandhi-src Could you ask around in Slack to see what behavior people expect with this? Once we have that, we'll prioritize a fix. Thanks!

@chrispine chrispine added the good first issue Good for newcomers label Feb 22, 2022
@varungandhi-src
Copy link
Contributor Author

Poll in Slack didn't gather a lot of data points:

  • +4 for stdout (including my own vote)
  • +2 for stderr

@mrnugget
Copy link
Contributor

I think the answers to this SO question are quite good and make sense:

  • if the user explicitly asked for --help output by providing --help then the help text is not an error and should be displayed on stdout
  • if the user can a command the wrong way and we need to print help output to guide them, it should be printed on stderr
  • when in doubt or if it's hard to implement: use stdout for everything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants