-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
56 lines (49 loc) · 1.52 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'bundler/gem_tasks'
desc "create the git hug command alias"
task :githug do
`git config --global alias.hug '!githug'`
def interface
puts purple("\n=======================================\n=============== githug ================\n=======================================\n")
puts "Install githug command line utility? (y/n)\n\n"
response = $stdin.gets.chomp
if response == "y"
git_path = `which git`.chomp
githug_path = `which githug`.chomp
githug_symlink = git_path.gsub(/git/, 'githug').chomp
begin
puts "\n"
sh %{sudo cp #{githug_path} #{githug_symlink} > /dev/null 2>&1\n}
puts purple("\nSuccessfully installed githug command.")
rescue Exception
overwrite
end
elsif response == "n"
puts red("\nDidn't install anything.")
else
interface
end
end
def overwrite
puts red("Overwrite existing command? (y/n)\n\n")
response = $stdin.gets.chomp
if response == "y"
git_path = `which git`.chomp
githug_path = `which githug`.chomp
githug_symlink = git_path.gsub(/git/, 'githug').chomp
puts "\n"
sh %{sudo cp -fi #{githug_path} #{githug_symlink} > /dev/null 2>&1\n}
puts purple("\nSuccessfully installed githug command.")
elsif response == "n"
puts red("\nDidn't install anything.")
else
overwrite
end
end
def red(text)
"\e[31m\e[1m#{text}\e[0m\e[0m"
end
def purple(text)
"\e[35m\e[1m#{text}\e[0m\e[0m"
end
interface
end