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

Errors should go to stderr #40

Open
danp opened this issue Jun 11, 2014 · 2 comments
Open

Errors should go to stderr #40

danp opened this issue Jun 11, 2014 · 2 comments

Comments

@danp
Copy link
Contributor

danp commented Jun 11, 2014

I accidentally ran:

$ heroics-generate -h "Content-Type: application/json" ... > x.rb

when I should have used -H. The error output went to stdout and got redirected to x.rb.

@schneems
Copy link
Collaborator

schneems commented Aug 27, 2020

I'm still seeing this behavior:

$ bin/heroics-generate -h "Content-Type: application/json" > out.tmp
⛄ 2.7.1 🚀  ~/Documents/projects/tmp/heroics (schneems/fix-heroku-api)
$ cat out.tmp
Usage: heroics-generate module_name schema_filepath url
       heroics-generate configuration-file-path.rb
# Params only allowed when using the first form:
    -h, --help                       Display this screen
    -H, --header [HEADER]            Include header with all requests
    -c, --cache-dir [PATH]           Content cache directory (~ is automatically expanded)

From an interface perspective, I think it would be more clear and less error-prone if the command took an explicit file input, something like:

$ heroics-generate MyApp schema.json https://api.myapp.com --output=client.rb

Otherwise I agree that putting warnings and errors to stderr instead of stdout helps clarify issues.

@tkenvin
Copy link

tkenvin commented Sep 30, 2020

I think that this is probably correct behaviour because -h or --help is supposed to print the usage to stdout and exit with 0. In contrast try to provide a valid option such as -c or -H without the required argument or an invalid option such as -k, in these cases error messages are sent to stderr and a non-zero exit value is returned.

What I don't understand, and this may be my fault, is when the usage output says:

# Params only allowed when using the first form:

when this doesn't/shouldn't apply to -h.

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

3 participants