Skip to content

Conversation

paulomarg
Copy link

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.

@paulomarg paulomarg requested a review from a team as a code owner May 17, 2024 15:30
@paulomarg paulomarg requested review from SevInf and removed request for a team May 17, 2024 15:30
@CLAassistant
Copy link

CLAassistant commented May 17, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

codspeed-hq bot commented May 17, 2024

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%

@SevInf SevInf changed the title Add silent / quiet global CLI flag feat(cli): Add silent / quiet global CLI flag May 27, 2024
Copy link
Contributor

@SevInf SevInf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @paulomarg
Thank you for submitting the PR. --quiet flag makes sense, however, I am pretty sure this PR won't quite achieve the functionality you want - unfortunately, we are pretty bad at centralizing our logging and there are bunch of other places within the CLI where rogue console.log might slip in.
If you want to do an attempt at centralized logging, we'll take it. However, that might be a lot of work and I think there is way for us to proceed with this PR - just that before we can merge it, we should at least be sure that we won't make this logging situation worse in the future. And for that we'd need to snapshot output from real commands, not the fake one. You can find the examples of how to do it in cli/src/__tests__ and migrate/src/__tests__.

Additionally, small nitpick - I don't think there is a good reason to have both --silent and --quiet flag, I'd prefer we'd just keep --quiet for now.

Thank you again for this PR and let me know if you need any help.

@paulomarg
Copy link
Author

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.

@paulomarg paulomarg closed this May 28, 2024
@SevInf
Copy link
Contributor

SevInf commented Jun 5, 2024

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.

@davecarlson
Copy link
Contributor

@SevInf , surely "some" fuctionality is better than a perfect solution for now. It can always be adjusted and improved in the future.

as per #23192 (comment)

@SevInf
Copy link
Contributor

SevInf commented Jun 19, 2024

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

@davecarlson
Copy link
Contributor

sweet, thank you . that hopefully will do :)

@paulomarg
Copy link
Author

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.

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 this pull request may close these issues.

CLI: --silent or --quiet to disable any non warning or error output

4 participants