diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index 411acac84e..584904791e 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -1,34 +1,51 @@ class Caveats - def self.print f + attr_reader :f + + def initialize(f) + @f = f + end + + def caveats + caveats = [] + caveats << f.caveats + caveats << f.keg_only_text rescue nil if f.keg_only? + caveats << bash_completion_caveats + caveats << zsh_completion_caveats + caveats << plist_caveats + caveats.compact.join("\n") + end + + def empty? + caveats.empty? + end + + private + + def keg + @keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d| + Keg.new(d.realpath) rescue nil + end.compact.first + end + + def bash_completion_caveats + if keg and keg.completion_installed? :bash then <<-EOS.undent + Bash completion has been installed to: + #{HOMEBREW_PREFIX}/etc/bash_completion.d + EOS + end + end + + def zsh_completion_caveats + if keg and keg.completion_installed? :zsh then <<-EOS.undent + zsh completion has been installed to: + #{HOMEBREW_PREFIX}/share/zsh/site-functions + EOS + end + end + + def plist_caveats s = [] - - unless f.caveats.to_s.strip.empty? - s << f.caveats - end - - keg = Keg.new(f.prefix) rescue nil - keg ||= Keg.new(f.opt_prefix.realpath) rescue nil - keg ||= Keg.new(f.linked_keg.realpath) rescue nil - - if keg and keg.completion_installed? :bash - s << "\n" unless s.empty? - s << <<-EOS.undent - Bash completion has been installed to: - #{HOMEBREW_PREFIX}/etc/bash_completion.d - EOS - end - - if keg and keg.completion_installed? :zsh - s << "\n" unless s.empty? - s << <<-EOS.undent - zsh completion has been installed to: - #{HOMEBREW_PREFIX}/share/zsh/site-functions - EOS - end - if f.plist or (keg and keg.plist_installed?) - s << "\n" unless s.empty? - destination = f.plist_startup ? '/Library/LaunchDaemons' \ : '~/Library/LaunchAgents' @@ -79,7 +96,6 @@ class Caveats end end end - - ohai 'Caveats', s unless s.empty? + s.join("\n") unless s.empty? end end diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index ffbc93038b..7c512fa232 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -120,7 +120,8 @@ module Homebrew extend self Homebrew.dump_options_for_formula f end - Caveats.print f + c = Caveats.new(f) + ohai 'Caveats', c.caveats unless c.empty? rescue FormulaUnavailableError # check for DIY installation diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 2216905764..db9ade9cad 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -154,7 +154,12 @@ class FormulaInstaller check_infopages end - Caveats.print f + c = Caveats.new(f) + + unless c.empty? + @show_summary_heading = true + ohai 'Caveats', c.caveats + end end def finish @@ -175,7 +180,7 @@ class FormulaInstaller install_plist fix_install_names - ohai "Summary - #{f.name}" if ARGV.verbose? or show_summary_heading + ohai "Summary" if ARGV.verbose? or show_summary_heading print "🍺 " if MacOS.version >= :lion print "#{f.prefix}: #{f.prefix.abv}" print ", built in #{pretty_duration build_time}" if build_time