cmd/search: better handle non-TTY output.

When `stdout` is not a TTY then using `ohai` is a bit unpleasant as it
prevents using pipes to do cool things with the output.
This commit is contained in:
Mike McQuaid 2022-11-01 13:51:13 +00:00
parent fa2649dde7
commit 8145d516e2
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829

View File

@ -146,9 +146,21 @@ module Homebrew
print_formulae &&= all_formulae.any?
print_casks &&= all_casks.any?
ohai "Formulae", Formatter.columns(all_formulae) if print_formulae
if print_formulae
if $stdout.tty?
ohai "Formulae", Formatter.columns(all_formulae)
else
puts all_formulae
end
end
puts if print_formulae && print_casks
ohai "Casks", Formatter.columns(all_casks) if print_casks
if print_casks
if $stdout.tty?
ohai "Casks", Formatter.columns(all_casks)
else
puts all_casks
end
end
count = all_formulae.count + all_casks.count