2023-10-08 04:57:23 +02:00
|
|
|
local args = { ... }
|
|
|
|
|
2023-10-08 05:18:41 +02:00
|
|
|
local target_branch = "main"
|
2023-10-08 05:25:42 +02:00
|
|
|
local bin_path = "/bin/"
|
2023-10-08 05:18:41 +02:00
|
|
|
|
2023-10-08 04:57:23 +02:00
|
|
|
local program_name = args[1]
|
|
|
|
if program_name == nil then
|
|
|
|
print("Usage: lupdate <program_name>")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2023-10-08 05:18:41 +02:00
|
|
|
response = http.get("https://gitea.layla.gg/layla/computercraft/raw/branch/" .. target_branch .. "/" .. program_name .. ".lua", nil)
|
|
|
|
|
|
|
|
io.write("Updating " .. program_name .. ".lua\n")
|
2023-10-08 05:02:31 +02:00
|
|
|
|
|
|
|
if response.getResponseCode() == 200 then
|
2023-10-08 05:18:41 +02:00
|
|
|
|
2023-10-08 05:22:39 +02:00
|
|
|
file = fs.open(bin_path .. program_name .. ".lua", "w")
|
2023-10-08 05:02:31 +02:00
|
|
|
file.write(response.readAll())
|
|
|
|
file.close()
|
2023-10-08 05:18:41 +02:00
|
|
|
|
2023-10-08 05:22:39 +02:00
|
|
|
-- check if program is in path
|
|
|
|
if not shell.resolveProgram(program_name) then
|
2023-10-08 05:24:38 +02:00
|
|
|
io.write("Program not in path, adding to path\n")
|
2023-10-08 05:22:39 +02:00
|
|
|
shell.setPath(shell.path() .. ":" .. bin_path)
|
|
|
|
end
|
2023-10-08 05:18:41 +02:00
|
|
|
|
2023-10-08 05:24:38 +02:00
|
|
|
io.write("Updated " .. program_name .. ".lua\n")
|
2023-10-08 05:02:31 +02:00
|
|
|
else
|
2023-10-08 05:24:38 +02:00
|
|
|
io.write("Failed to update " .. program_name .. ".lua\n")
|
|
|
|
io.write(response)
|
2023-10-08 04:57:23 +02:00
|
|
|
end
|
|
|
|
|