computercraft/lupdate.lua
2023-10-08 00:19:55 -04:00

28 lines
682 B
Lua

local args = { ... }
local target_branch = "main"
local bin_path = "/bin/"
local program_name = args[1]
if program_name == nil then
print("Usage: lupdate <program_name>")
return
end
response = http.get("https://gitea.layla.gg/layla/computercraft/raw/branch/" .. target_branch .. "/" .. program_name .. ".lua", nil)
io.write("Updating " .. program_name .. ".lua\n")
if response.getResponseCode() == 200 then
file = fs.open(bin_path .. program_name .. ".lua", "w")
file.write(response.readAll())
file.close()
io.write("Updated " .. program_name .. ".lua\n")
else
io.write("Failed to update " .. program_name .. ".lua\n")
io.write(response)
end