Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- created by hildenae
- -- Public domain
- if not http then
- error("The Computercraft HTTP API is not enabled")
- end
- function main(args)
- if #args < 1 then
- help()
- elseif args[1] == "--update" then
- update_self()
- elseif #args < 4 then
- help()
- else
- local a=args
- branch = "master"
- if a[1] == "--branch" or a[1] == "-b" then
- branch=a[2]
- i=1
- for key,value in pairs(args) do
- if key > 2 then
- a[i] = value
- i=i+1
- end
- end
- end
- for path in string.gmatch(a[3], "[^,]+") do
- download(a, branch, path)
- end
- end
- end
- function download(args, branch, path)
- print("Downloading " .. path)
- url = "https://raw.github.com/"..args[1].."/"..args[2].."/"..branch.."/"..path
- local content = http.get(url)
- fs.delete(path)
- local file = fs.open(path, "w")
- file.write(content.readAll())
- file.close()
- end
- function update_self()
- print("Will update self (master branch)")
- download({"Kagee","cc"},"master", "github")
- end
- function help()
- print("Arguments:")
- print("github <user> <repo> <path[s] separated by ,>")
- print("--update script will update itself")
- print("--branch <branch> as first arguments will download from <branch>")
- error()
- end
- main({...})
Advertisement
Add Comment
Please, Sign In to add comment