ugexe / zef

Raku Module Management
Artistic License 2.0
211 stars 45 forks source link

zef --help writes to stderr #477

Open 2colours opened 2 years ago

2colours commented 2 years ago

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 commented 2 years ago

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>

https://github.com/ugexe/zef/blob/0952bcbcbb77f2347062a7c96089a20e0219d549/lib/Zef/CLI.rakumod#L1024

2colours commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

2colours commented 2 years ago

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...