oh1 stdout display function

This commit is contained in:
Max Howell 2011-08-23 23:19:32 +01:00
parent 31885c2a99
commit 9713bb76b0

View File

@ -8,6 +8,11 @@ class Tty
def yellow; underline 33 ; end def yellow; underline 33 ; end
def reset; escape 0; end def reset; escape 0; end
def em; underline 39; end def em; underline 39; end
def green; color 92 end
def width
`/usr/bin/tput cols`.strip.to_i
end
private private
def color n def color n
@ -27,11 +32,16 @@ end
# 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, *sput def ohai title, *sput
title = title.to_s[0, `/usr/bin/tput cols`.strip.to_i-4] unless ARGV.verbose? title = title.to_s[0, Tty.width - 4] unless ARGV.verbose?
puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}" puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}"
puts sput unless sput.empty? puts sput unless sput.empty?
end end
def oh1 title
title = title.to_s[0, Tty.width - 4] unless ARGV.verbose?
puts "#{Tty.green}==> #{Tty.reset}#{title}"
end
def opoo warning def opoo warning
puts "#{Tty.red}Warning#{Tty.reset}: #{warning}" puts "#{Tty.red}Warning#{Tty.reset}: #{warning}"
end end
@ -272,9 +282,11 @@ module MacOS extend self
end end
def xcode_version def xcode_version
@xcode_version ||= begin
`xcodebuild -version 2>&1` =~ /Xcode (\d(\.\d)*)/ `xcodebuild -version 2>&1` =~ /Xcode (\d(\.\d)*)/
$1 $1
end end
end
def llvm_build_version def llvm_build_version
unless xcode_prefix.to_s.empty? unless xcode_prefix.to_s.empty?
@ -331,7 +343,7 @@ module MacOS extend self
end end
def lion? def lion?
10.7 == MACOS_VERSION 10.7 <= MACOS_VERSION #Actually Lion or newer
end end
def prefer_64_bit? def prefer_64_bit?