Files
computercraft/lupdate.lua
2023-10-07 23:22:39 -04:00

34 lines
868 B
Lua

local args = { ... }
local target_branch = "main"
local bin_path = "/"
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()
-- check if program is in path
if not shell.resolveProgram(program_name) then
print("Program not in path, adding to path")
shell.setPath(shell.path() .. ":" .. bin_path)
end
print("Updated " .. program_name .. ".lua")
else
print("Failed to update " .. program_name .. ".lua")
print(response)
end