Qivex

qua-install

Jan 30th, 2020 (edited)
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- CONSTANTS
  2. local BASE_URL = "https://raw.githubusercontent.com/Qivex/qua/master/"
  3. local BASE_PATH = "apis/qua"
  4. local FILES = {
  5.     "/init",
  6.     "/cc/init",
  7.     "/cc/color",
  8.     "/cc/side",
  9.     "/core/init",
  10.     "/core/assert",
  11.     "/core/class",
  12.     "/core/config",
  13.     "/ui/init",
  14.     "/ui/animation",
  15.     "/ui/box",
  16.     "/ui/button",
  17.     "/ui/clickable",
  18.     "/ui/display",
  19.     "/ui/drawable",
  20.     "/ui/image",
  21.     "/ui/label",
  22.     "/ui/markup",
  23.     "/ui/multiscreen",
  24.     "/ui/screen",
  25.     "/ui/window",
  26.     "/tools/init",
  27.     "/tools/array",
  28.     "/tools/rsqueue",
  29.     "/tools/shortcuts"
  30. }
  31.  
  32.  
  33. -- IMPLEMENTATION
  34. local x,y = term.getCursorPos()
  35.  
  36. local log = function(text)
  37.     term.clearLine()
  38.     term.setCursorPos(x,y)
  39.     term.write(text)
  40. end
  41.  
  42. fs.delete(BASE_PATH)
  43. for index, file in pairs(FILES) do
  44.     local url = BASE_URL .. file .. ".lua"
  45.     local path = BASE_PATH .. file
  46.     local dir = path:match("^(.*)/.-$")
  47.     if not fs.isDir(dir) then
  48.         fs.makeDir(dir)
  49.     end
  50.     if fs.exists(path) then
  51.         fs.delete(path)
  52.     end
  53.     log("Downloading '" .. file .. "' (" .. index .. " of " .. #FILES .. ")")
  54.     http.request(url)
  55.     local event, url, response = os.pullEvent()
  56.     if event == "http_success" then
  57.         local content = response.readAll()
  58.         response.close()
  59.         local file = fs.open(path, "w")
  60.         file.write(content)
  61.         file.close()
  62.     else
  63.         error("Failure: Not found or interrupted - try again.")
  64.     end
  65. end
  66.  
  67. log("")
RAW Paste Data