Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --gitGet-github raw downloader--
- --Made by Mavric on youtube--
- --functions--
- --downloads a github raw--
- function gitGet(args)
- --check that a git raw path was entered--
- if args[2] == nil then
- error("args[2]: must enter git raw path (the part after https://raw.githubusercontent.com/)")
- --check that a path was entered--
- elseif args[3] == nil then
- error("args[3]: must enter path")
- --check the path doesnt already exist--
- elseif fs.exists(args[3]) then
- error("args[3]: path already exists")
- end
- --make the http get--
- local download = http.get("https://raw.githubusercontent.com/".. args[2])
- --open the file and empty contents--
- local file = fs.open(args[3], "w")
- --write text to file--
- while true do
- local text = download.readLine()
- if text == nil then
- file.close()
- return true
- end
- file.writeLine(text)
- end
- end
- --installs a group of files from a github raw list--
- function gitInstall(args)
- --default version is main (latest)--
- local version = "main"
- --check that a git repo path was entered--
- if args[2] == nil then
- error("args[2]: must enter get repo path (the part after https://github.com/ but just the username and repo name)")
- --if version give replace default--
- elseif args[3] ~= nil then
- version = args[3]
- end
- --http the install list--
- local list = http.get("https://raw.githubusercontent.com/".. args[2].. "/".. version.. "/install.txt")
- --make dir to put files--
- local dir = list.readLine()
- --check the dir doesnt already exist--
- if fs.isDir(dir) == true then
- error("dir already exists")
- else
- fs.makeDir(dir)
- end
- --download each file--
- while true do
- local text = list.readLine()
- local text2 = list.readLine()
- if text == nil or text2 == nil or text == "" or text2 == "" then
- break
- end
- local args2 = {"get", text, (text2)}
- printError(args2[2])
- print(args2[3])
- gitGet(args2)
- end
- end
- --main code--
- --run gitGet or gitInstall based on arg[1]--
- if arg[1] == "get" then
- gitGet(arg)
- elseif arg[1] == "install" then
- gitInstall(arg)
- else
- error("args[1]: must enter get or install")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement