-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
343b205
commit b1232d4
Showing
1 changed file
with
8 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,43 @@ | ||
|
||
# frozen_string_literal | ||
require 'inifile' | ||
require 'open-uri' | ||
#require 'facter' | ||
# TODO: bring back helper | ||
require 'colorize' | ||
# module to download Packages | ||
module Pkg | ||
def self.findPkg(query) | ||
$query = query | ||
puts "Getting #{$query}" | ||
puts "Starting install of #{$query}".colorize(:yellow) | ||
Pkg.getPkgfile | ||
end | ||
|
||
def self.getPkgfile | ||
pfr = URI.open("https://raw.githubusercontent.com/Pandademic/Latte/master/pkgs/#{$query}.ini").read | ||
packageFileURL = "https://raw.githubusercontent.com/Pandademic/Latte/master/pkgs/#{$query}.ini" | ||
puts "Package file:#{pfr}" | ||
# implemnt no donwload of pkg file by using pfr | ||
system("curl -O #{packageFileURL}") | ||
puts 'package file download complete' | ||
puts 'package file download complete!'.colorize(:green) | ||
Pkg.downloadLatest | ||
end | ||
|
||
def self.downloadLatest | ||
file = IniFile.load("#{$query}.ini") | ||
puts 'loaded file' | ||
puts 'Package file read!'.colorize(:green) | ||
pkgdata = file['package'] | ||
zipsupport = pkgdata['Media'] | ||
if zipsupport == true | ||
@RURL = pkgdata['MediaUrl'] | ||
system "curl -O #{@RURL}" | ||
puts "#$query install success!".colorize(:green) | ||
else | ||
@Isc = pkgdata['InstallCommand'] # install command | ||
system @Isc.to_s | ||
puts "#$query installed successfully".colorize(:green) | ||
end | ||
end | ||
end | ||
@param1 = ARGV[1] | ||
#$os = Facter['osfamily'].value | ||
abort('That is not a command') while ARGV.empty? | ||
if ARGV[0] == 'add' | ||
Pkg.findPkg @param1.to_s | ||
elsif Pkg.findPkg @param1.to_s | ||
else | ||
puts 'Unknown Command' | ||
puts 'Unknown Command' .colorize(:red) | ||
exit 1 | ||
end |