92 lines
1.6 KiB
Ruby
Executable File
92 lines
1.6 KiB
Ruby
Executable File
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
|
|
# Inspired by: https://raw.githubusercontent.com/Homebrew/install/master/install
|
|
require 'tmpdir'
|
|
|
|
module Tty
|
|
module_function
|
|
|
|
def blue
|
|
bold 34
|
|
end
|
|
|
|
def red
|
|
bold 31
|
|
end
|
|
|
|
def reset
|
|
escape 0
|
|
end
|
|
|
|
def bold(n = 39)
|
|
escape "1;#{n}"
|
|
end
|
|
|
|
def underline
|
|
escape "4;39"
|
|
end
|
|
|
|
def escape(n)
|
|
"\033[#{n}m" if STDOUT.tty?
|
|
end
|
|
end
|
|
|
|
class Array
|
|
def shell_s
|
|
cp = dup
|
|
first = cp.shift
|
|
cp.map { |arg| arg.gsub " ", "\\ " }.unshift(first).join(" ")
|
|
end
|
|
end
|
|
|
|
def ohai(*args)
|
|
puts "#{Tty.blue}==>#{Tty.bold} #{args.shell_s}#{Tty.reset}"
|
|
end
|
|
|
|
def warn(warning)
|
|
puts "#{Tty.red}Warning#{Tty.reset}: #{warning.chomp}"
|
|
end
|
|
|
|
def system(*args)
|
|
abort "Failed during: #{args.shell_s}" unless Kernel.system(*args)
|
|
end
|
|
|
|
def getc
|
|
system "/bin/stty raw -echo"
|
|
if STDIN.respond_to?(:getbyte)
|
|
STDIN.getbyte
|
|
else
|
|
STDIN.getc
|
|
end
|
|
ensure
|
|
system "/bin/stty -raw echo"
|
|
end
|
|
|
|
def wait_for_user
|
|
puts
|
|
puts "Press RETURN to continue or any other key to abort"
|
|
c = getc
|
|
# we test for \r and \n because some stuff does \r instead
|
|
abort unless (c == 13) || (c == 10)
|
|
end
|
|
|
|
class Version
|
|
include Comparable
|
|
attr_reader :parts
|
|
|
|
def initialize(str)
|
|
@parts = str.split(".").map { |p| p.to_i }
|
|
end
|
|
|
|
def <=>(other)
|
|
parts <=> self.class.new(other).parts
|
|
end
|
|
end
|
|
|
|
ohai "This script will uninstall:"
|
|
puts "/Applications/xcbuddy.app"
|
|
puts "/usr/local/bin/xcbuddy"
|
|
wait_for_user
|
|
ohai "Uninstalling"
|
|
system("rm -rf /Applications/xcbuddy.app 2> /dev/null")
|
|
system("rm -f /usr/local/bin/xcbuddy 2> /dev/null")
|
|
ohai "Uninstalled" |