Prettier install output

This way caveats and other warnings/errors don't appear connected to the Summary text.
This commit is contained in:
Max Howell 2009-09-16 19:29:43 +01:00
parent b3c6c3f591
commit 357751633e
2 changed files with 17 additions and 15 deletions

View File

@ -4,6 +4,8 @@ require 'formula'
require 'keg' require 'keg'
require 'brew.h' require 'brew.h'
show_summary_heading = false
def install f def install f
build_time = nil build_time = nil
@ -37,7 +39,11 @@ def install f
raise raise
end end
ohai "Caveats", f.caveats, '' if f.caveats
ohai "Caveats", f.caveats
show_summary_heading = true
end
ohai 'Finishing up' if ARGV.verbose? ohai 'Finishing up' if ARGV.verbose?
begin begin
@ -46,6 +52,7 @@ def install f
opoo "The cleaning step did not complete successfully" opoo "The cleaning step did not complete successfully"
puts "Still, the installation was successful, so we will link it into your prefix" puts "Still, the installation was successful, so we will link it into your prefix"
ohai e, e.inspect if ARGV.debug? ohai e, e.inspect if ARGV.debug?
show_summary_heading = true
end end
raise "Nothing was installed to #{f.prefix}" unless f.installed? raise "Nothing was installed to #{f.prefix}" unless f.installed?
@ -59,6 +66,7 @@ def install f
unless paths.include? rootbin unless paths.include? rootbin
opoo "#{rootbin} is not in your PATH" opoo "#{rootbin} is not in your PATH"
puts "You can amend this by altering your ~/.bashrc file" puts "You can amend this by altering your ~/.bashrc file"
show_summary_heading = true
end end
end end
end end
@ -70,11 +78,10 @@ def install f
puts "The package built, but is not symlinked into #{HOMEBREW_PREFIX}" puts "The package built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts "You can try again using `brew link #{f.name}'" puts "You can try again using `brew link #{f.name}'"
ohai e, e.inspect if ARGV.debug? ohai e, e.inspect if ARGV.debug?
ohai "Summary" show_summary_heading = true
else
ohai "Summary" if ARGV.verbose?
end end
ohai "Summary" if ARGV.verbose? or show_summary_heading
print "#{f.prefix}: #{f.prefix.abv}" print "#{f.prefix}: #{f.prefix.abv}"
print ", built in #{pretty_duration build_time}" if build_time print ", built in #{pretty_duration build_time}" if build_time
puts puts

View File

@ -22,15 +22,10 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# args are additional inputs to puts until a nil arg is encountered # args are additional inputs to puts until a nil arg is encountered
def ohai title, *args def ohai title, *sput
return if args.length > 0 and args[0].nil? title = title[0, `tput cols`.strip.to_i-4] unless ARGV.verbose?
n=`tput cols`.strip.to_i-4 puts "\033[0;34m==>\033[0;0;1m #{title}\033[0;0m"
n=title.length if ARGV.verbose? puts *sput unless sput.empty?
puts "\033[0;34m==>\033[0;0;1m #{title[0,n]}\033[0;0m"
args.each do |arg|
return if arg.nil?
puts arg
end
end end
# shows a warning in delicious pink # shows a warning in delicious pink