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

zef --help writes to stderr #477

Open
2colours opened this issue Nov 2, 2022 · 8 comments
Open

zef --help writes to stderr #477

2colours opened this issue Nov 2, 2022 · 8 comments

Comments

@2colours
Copy link

2colours commented Nov 2, 2022

Hi,

I've been running circles to get this confirmed, I rather open an issue now.

The zef --help is quite huge; when trying to grep to it, I noticed that actually it writes to the standard error rather than the standard output. I know that |& can help with piping the error handler but regardless, I don't think this is the right thing to do. It doesn't make logical sense (the command succeeded and its content is a legitimate product of it) and also it doesn't match default Raku CLI behavior - CLI tools created with Raku write the help to stdout when it's invoked on purpose.

Environment: 5.4.0-47-generic #51-Ubuntu SMP Fri Sep 4 19:50:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux with Rakudo v2022.07.

@ugexe
Copy link
Owner

ugexe commented Nov 2, 2022

I imagine it was originally written that way to be consistent with the help message generated when, for example, no arguments are given:

raku -e 'sub MAIN($foo) { }' --help
Usage:
  -e '...' <foo>

raku -e 'sub MAIN($foo) { }' > /dev/null
Usage:
  -e '...' <foo>

multi sub MAIN(Bool :h(:help($))) {

@2colours
Copy link
Author

2colours commented Nov 6, 2022

Could be but at the end of the day, if you pass only --help to a CLI that wants arguments, it will also write to stdout. So right now it seems that multi just overrides the default behavior to the opposite and I can't see the benefit of this.

@ugexe
Copy link
Owner

ugexe commented Nov 6, 2022

There are other considerations as well. For instance https://github.com/Raku/Blin/blob/253df4c042a1fb8cd0fd92ccedf9ce3fb9bcca70/lib/Blin/Tester/Zef.rakumod#L26-L27 (and other code like this) should be updated to use run(..., :merge).out instead of run(..., :err).err for the immediate future

@2colours
Copy link
Author

2colours commented Nov 9, 2022

Yes, "immediate future" because I think depending solely on stderr was a mistake whether the test passed or not.

I can try to hunt these locations down in the code if that moves the case of the zef help forward.

@ugexe
Copy link
Owner

ugexe commented Nov 10, 2022

Yes, that would expedite the process. Another instance is https://github.com/lizmat/Zef-Configuration/blob/11a474467f9f8eed8a00108adbe843e73090b2c9/lib/Zef/Configuration.rakumod#L415-L416

There used to be a bot/tool in IRC that could grep the ecosystem that would probably prove useful

@2colours
Copy link
Author

Yes, the bot still exists https://gist.github.com/Whateverable/f3c945c5c02a7acb811e68163e9855bf but I'd assume it can only check p6c content. If it could be adopted to use REA, then it would be quite useful again...

@ugexe
Copy link
Owner

ugexe commented Nov 13, 2022

That query isn't really sufficient. Something like zef.*?--help would be better.

@2colours
Copy link
Author

2colours commented Nov 14, 2022

The difference is not big at least: https://gist.github.com/Whateverable/7016caa7a3edaa7ce6e692ffa7df4bd7

To be honest, what really should lead to some questions is the fact that anyone decides to depend upon the content (let alone the handle) of the help output of any tool really...

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 a pull request may close this issue.

2 participants