Add gitea.lua

This commit is contained in:
Dominic Zimmer 2020-07-04 12:22:52 +02:00
parent 33878f84da
commit 7926a88258

20
gitea.lua Normal file
View File

@ -0,0 +1,20 @@
-- 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()
end