-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSoda Installer.lua
42 lines (39 loc) · 1.58 KB
/
Soda Installer.lua
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
--# Main
local url = "https://raw.githubusercontent.com/Utsira/Soda/master/tabs/"
local function install(data)
--parse plist into list of tab files
local array = data:match("<key>Buffer Order</key>%s-<array>(.-)</array>")
local files = {}
for tabName in array:gmatch("<string>(.-)</string>%s") do
table.insert(files, {name = tabName})
end
--success function
local function success(n, name, data)
if not data then alert("No data", name) return end
print("Loaded "..n.."/"..#files..":"..name)
files[n].data = data
for _,v in ipairs(files) do
if not v.data then
return --quit this function if any files have missing data
end
end
--if all data is present then save...
for i,v in ipairs(files) do
saveProjectTab(v.name, v.data)
print("Saved "..i.."/"..#files..":"..v.name)
end
for i,v in ipairs(files) do --load...
load(v.data)()
end
setup() --...and run
end
--request all the tab files
for i,v in ipairs(files) do
local function retry(error) --try each file twice, in case of time-outs
print(error, v.name.." not found, retrying")
http.request(url..v.name..".lua", function(data) success(i, v.name, data) end, function(error2) alert(error2, v.name.." not found") end)
end
http.request(url..v.name..".lua", function(data) success(i, v.name, data) end, retry)
end
end
http.request(url.."Info.plist", install, function (error) alert(error) end)