30 lines
963 B
Lua
30 lines
963 B
Lua
-- Use (and improve) this script to download files from https://gitea.leafbla.de/dominic/turtles/
|
|
--
|
|
-- Usage: gitea get FILENAME DESTINATION
|
|
--
|
|
-- FILENAME should have the format USERDIR/FILENAME
|
|
-- in order to access USERDIR/FILENAME.lua in the repository
|
|
--
|
|
-- DESTINATION is the name under which the script will be stored in the turtle
|
|
--
|
|
|
|
local args = {...}
|
|
filename = args[2]
|
|
if args[1] == "get" then
|
|
url = "https://gitea.leafbla.de/dominic/turtles/raw/branch/master/"..filename..".lua"
|
|
response = http.get(url)
|
|
local handle = io.open(args[3], "w")
|
|
handle:write(response.readAll())
|
|
handle:close()
|
|
response.close()
|
|
if args[2] == "update" then
|
|
url = "https://gitea.leafbla.de/dominic/turtles/raw/branch/master/"..filename..".lua"
|
|
response = http.get(url)
|
|
os.remove(args[3])
|
|
local handle = io.open(args[3], "w")
|
|
handle:write(response.readAll())
|
|
handle:close()
|
|
response.close()
|
|
end
|
|
end
|