Add silent / quiet global CLI flag
Closes #23192
As mentioned in the issue, there are some scenarios where we want to omit the regular message returned from a command, where the output might make it harder to spot legitimate issues, or bloats the output of some scripts.
To achieve that, this PR introduces a new global --quiet flag (aliased to --silent if I understood the setup correctly 😄) that simply ignores the message returned from a command, unless that is an Error.
With this, users can toggle the regular output off but still catch any errors thrown by commands so we don't accidentally hide problems. Messages logged directly by a command (assuming no normal flow messages are logged that way) are still output normally.
CodSpeed Performance Report
Merging #24232 will improve performances by 22.52%
Comparing paulomarg:add_silent_flag_to_cli (0ec450a) with paulomarg:add_silent_flag_to_cli (c9f0a71)
Summary
⚡ 1 improvements
✅ 2 untouched benchmarks
Benchmarks breakdown
| Benchmark | paulomarg:add_silent_flag_to_cli |
paulomarg:add_silent_flag_to_cli |
Change | |
|---|---|---|---|---|
| ⚡ | client generation 100 models with relations |
8 s | 6.6 s | +22.52% |
Hey, thanks for getting back to me! That was a good callout, I added some test that would check the actual output and it does seem like a lot of it isn't coming from the command return value (see the new snapshots), so my proposal was too shallow.
I agree that the right solution would have to be centralizing all of the logging and using the flag to turn that off instead, but unfortunately I won't have the time to do that :(
Thanks for taking the time to review, and I hope this PR helps whatever solution you end up implementing! I'm going to close it since it doesn't feel like it'll solve the problem.
No worries, @paulomarg, thank you for submitting the PR anyway. It won't be able to be merged is more of our failure than yours, to be honest, so, my apologies about that.
@SevInf , surely "some" fuctionality is better than a perfect solution for now. It can always be adjusted and improved in the future.
as per https://github.com/prisma/prisma/issues/23192#issuecomment-2097636494
@davecarlson I was not the one who closed the PR, but if you look at updated snapshots here, it is pretty far even from a baseline — generate message you are mentioning in the other issue is not affected at all, as an example, and it is still there when --silent flag is used. For that specific case though, 5.16.0 will have --no-hints flag.
sweet, thank you . that hopefully will do :)
I agree with @SevInf, unfortunately this PR just didn't do what it intended, since we still had a lot of output going out even with the flag. I don't think it should be merged in the state it was in as having the flag omit only some messages would probably make it worse.