homebrew-bundle
homebrew-bundle copied to clipboard
Feature Request: Respect `--quiet`/`-q` cli flag
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.
Thanks for the good write-up. What would you expect the output to be with --quiet
? Nothing unless there are errors?
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 asquiet
, plus logging changes to the system (i.e. things being installed or removed). -
verbose
: same asdefault
, 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"
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?
@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 🙂
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
I'd like this as well.
Let us know if you made some progress and stuck on something!
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.
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 leastcmd/bundle.rb
usesonoe
in a few places, implying thatohai
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.