From 653294f3a593449d0671d478e461059e1f046682 Mon Sep 17 00:00:00 2001 From: Layla Manley Date: Sat, 7 Oct 2023 23:18:41 -0400 Subject: [PATCH] iteration --- lupdate.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lupdate.lua b/lupdate.lua index 428df36..4459d08 100644 --- a/lupdate.lua +++ b/lupdate.lua @@ -1,17 +1,25 @@ local args = { ... } +local target_branch = "main" + local program_name = args[1] if program_name == nil then print("Usage: lupdate ") return end -response = http.get("https://gitea.layla.gg/layla/computercraft/raw/branch/main/" .. program_name .. ".lua", nil) +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 - local file = fs.open("/rom/programs/" .. program_name .. ".lua", "w") + + file = fs.open(program_name .. ".lua", "w") file.write(response.readAll()) file.close() + + fs.move(program_name .. ".lua", "/rom/programs/" .. program_name .. ".lua") + print("Updated " .. program_name .. ".lua") else print("Failed to update " .. program_name .. ".lua")