-
Notifications
You must be signed in to change notification settings - Fork 0
/
latte.rb
48 lines (46 loc) · 1.33 KB
/
latte.rb
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
# frozen_string_literal
require 'inifile'
require 'open-uri'
require 'colorize'
# module to download Packages
module Pkg
def self.findPkg(query)
$query = query
puts "Starting install of #{$query}".colorize(:yellow)
Pkg.getPkgfile
end
def self.getPkgfile
if $TRAY == "main"
packageFileURL = "https://raw.githubusercontent.com/Pandademic/Latte/master/pkgs/#{$query}.ini"
else
packageFileURL= "https://raw.githubusercontent.com/#{$TRAY}/master/pkgs/#{$query}.ini"
end
system("curl -O #{packageFileURL}")
puts 'package file download complete!'.colorize(:green)
Pkg.downloadLatest
end
def self.downloadLatest
file = IniFile.load("#{$query}.ini")
puts 'Package file read!'.colorize(:green)
pkgdata = file['package']
zipsupport = pkgdata['Media']
if zipsupport == true
@RURL = pkgdata['MediaUrl']
system("curl -O #{@RURL}")
puts "Installed #{$query} from #{$TRAY}".colorize(:green)
else
@Isc = pkgdata['InstallCommand'] # install command
system @Isc.to_s
puts "#{$query} installed successfully".colorize(:green)
end
end
end
@param1 = ARGV[1]
$TRAY = ARGV[2].chomp(":tray")
if ARGV[0] == 'add'
puts "Starting install of #@param1 from #$TRAY".colorize(:green)
Pkg.findPkg @param1.to_s
else
puts 'Unknown Command'.colorize(:red)
exit 1
end