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
|
# File 'lib/grp.rb', line 8
def self.ask_and_download
puts "Git repository: (username/repo)".colorize(:grey)
repo_input = gets.chomp
username, repo = repo_input.split("/", 2)
unless username && repo
puts "Invalid format. Use username/repo.".colorize(:red)
exit
end
puts "==> Installing #{repo_input}...".colorize(:green)
begin
success = system("git clone -q https://github.com/#{username}/#{repo} #{repo}")
unless success
puts "Repository not found or clone failed.".colorize(:red)
exit
end
rescue => e
puts "An error occurred: #{e.message}".colorize(:red)
exit
end
puts "==> Repository downloaded!".colorize(:green)
system("cd #{repo}")
puts "==> Trying to find a install.grp in #{repo}".colorize(:green)
if File.exist?(File.join(repo, "install.grp"))
puts "install.grp found in #{repo}".colorize(:green)
puts "==> Installing #{repo}..."
system("ruby install.grp")
else
puts "install.grp not found in #{repo}".colorize(:red)
end
exit
end
|