Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- GitSnorr GitHub Downloader
- (c) 2013 Snorrful Systems
- --]]
- local version = "1.2"
- local function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function bar()
- term.clear()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.green)
- term.clearLine()
- print("GitSnorr GitHub Downloader")
- term.setBackgroundColor(colors.black)
- end
- clear()
- print("Loaded GitSnorr GitHub Downloader "..version)
- print("(c) 2013 Snorrful Systems")
- sleep(1)
- if not http then
- clear()
- print("HTTP API not enabled!")
- print("GitSnorr downloader requires")
- print("for your HTTP API to be")
- print("enabled! Enable it in your config.")
- sleep(5)
- clear()
- shell.run("shell")
- end
- bar()
- print("GitHub username")
- write("https://raw.github.com/")
- local user = read()
- bar()
- print("Repository on "..user)
- write(user.."/")
- local repo = read()
- bar()
- print("File to get from "..repo)
- print("Remember to include folders if it's in one")
- write(repo.."/")
- local repoFile = read()
- bar()
- print("Connecting and downloading...")
- local get = http.get("https://raw.github.com/"..user.."/"..repo.."/"..repoFile)
- if get then
- bar()
- print("Successfully downloaded "..repoFile)
- write("Save as: ")
- local saveAs = read()
- if fs.exists(saveAs) then
- bar()
- print("File already exists!")
- sleep(2)
- clear()
- shell.run("shell")
- else
- bar()
- print("Saving...")
- sleep(1)
- bar()
- local data = get.readAll()
- get.close()
- local file = fs.open(saveAs,"w")
- file.write(data)
- file.close()
- print("Saved as "..saveAs)
- sleep(2)
- clear()
- shell.run("shell")
- end
- else
- bar()
- print("Could not download!")
- print("Are you sure that repository exists?")
- print("Make sure you also have an internet connection.")
- sleep(4)
- clear()
- shell.run("shell")
- end
Add Comment
Please, Sign In to add comment