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

Feature Request: Respect --quiet/-q cli flag #1202

Closed
maxcbc opened this issue May 2, 2023 · 9 comments · Fixed by #1346
Closed

Feature Request: Respect --quiet/-q cli flag #1202

maxcbc opened this issue May 2, 2023 · 9 comments · Fixed by #1346

Comments

@maxcbc
Copy link

maxcbc commented May 2, 2023

Problem
Homebrew bundle has quite verbose output at times, such as the Using package_x output (source) when running brew bundle install.

brew bundle --help lists the standard homebrew --quiet/-q flag in its output, which is intended for use cases where the user wishes to suppress extraneous output. Currently homebrew bundle does not appear to respect this flag.

My Usecase
I use homebrew bundle as part as my standard dotfiles setup to maintain a consistent development setup across multiple macos devices and to minimise disaster recovery time.
As part of this, I run brew install --global --quiet --cleanup on every call to brew which would potentially change the state of my brewfile.
I'd like the --quiet flag to reduce the output from this command, so that it only tells me if it is installing/uninstalling packages/casks from my system.

Solution
Update homebrew bundle to respect the --quiet/-q flag by replacing relevant direct calls to puts with a custom log function which acts as a noop if the flag is active.

@maxcbc maxcbc changed the title Respect --quiet/-q cli flag Feature Request: Respect --quiet/-q cli flag May 2, 2023
@MikeMcQuaid
Copy link
Member

Thanks for the good write-up. What would you expect the output to be with --quiet? Nothing unless there are errors?

@maxcbc
Copy link
Author

maxcbc commented May 3, 2023

I think it is best to mirror the behaviour of the brew command, which I think would mean "Nothing unless there are errors" as you say.

Though, that aside, just as a cli user I'd expect:

  • quiet: log errors or prompts for input only (i.e. if something goes wrong or the user needs to elevate to sudo etc)
  • default: same as quiet, plus logging changes to the system (i.e. things being installed or removed).
  • verbose: same as default, plus logging where changes to the system aren't required (i.e. where something is already installed, etc).

The specific problem I'm trying to solve is that, when the system is already up to date with the brewfile, brew bundle install --global --quiet --cleanup will currently output $x+1$ lines i.e.

  • $x \times$ "Using <cask/package name>"
  • $1 \times$ "Homebrew Bundle complete! $x$ Brewfile dependencies now installed"

@MikeMcQuaid
Copy link
Member

  • quiet: log errors or prompts for input only (i.e. if something goes wrong or the user needs to elevate to sudo etc)

Agreed. I think the default and verbose already behaves as described so I think that'd be good scope for this issue.

@maxcbc Do you want to give this a go implementing it yourself? Happy to provide review and help on a partially working/CI failing draft PR?

@maxcbc
Copy link
Author

maxcbc commented May 4, 2023

@MikeMcQuaid Sure. It'll probably be a few weeks before I can get to it, but a good opportunity to refresh my ruby skills.
Watch this space 🙂

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@hermitmaster
Copy link

I'd like this as well.

@osalbahr
Copy link
Sponsor

Let us know if you made some progress and stuck on something!

@colindean
Copy link
Sponsor Member

Taking a look at this, there are 61 places we're using puts instead of calling a logging function.

@MikeMcQuaid Is there a reason not to use ohai for the majority of these? I see that at least cmd/bundle.rb uses onoe in a few places, implying that ohai is available.

colindean added a commit to colindean/homebrew-bundle that referenced this issue Sep 17, 2023
Work toward Homebrew#1202, but untested. I did this commit in a codespace
that is flailing.
@MikeMcQuaid
Copy link
Member

Taking a look at this, there are 61 places we're using puts instead of calling a logging function.

@MikeMcQuaid Is there a reason not to use ohai for the majority of these? I see that at least cmd/bundle.rb uses onoe in a few places, implying that ohai is available.

@colindean Yes. We should be using puts instead. This is what Homebrew/brew does. ohai is not any more of a logging function: it's just a puts with a prefix. Homebrew/brew also uses puts all over the place, intentionally.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants