Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function get(file)
- if not silent then
- write("Fetching "..file)
- end
- local response = http.get("https://raw.github.com/rodsn/mmtp/master/"..file)
- if response then
- local content = response.readAll()
- response.close()
- local f = fs.open("mmtp_files/"..file,"w")
- f.write(content)
- f.close()
- print(" [ok]")
- else
- if not silent then
- print(" [ERROR]")
- end
- end
- end
- function usage()
- prog = shell.getRunningProgram()
- print("Usage:")
- print(prog.." full <silent>")
- print(prog.." api <silent>")
- end
- function download( mode )
- if not silent then
- print("Download mode: "..mode)
- end
- if fs.exists("mmtp_files") and fs.isDir("mmtp_files") then
- if not silent then
- print("mmtp_files already exists, please delete it and try again.")
- end
- return
- else
- fs.makeDir("mmtp_files")
- if not silent then
- print("Downloading files to: mmtp_files")
- end
- end
- if mode == "full" then
- get("server")
- get("gui")
- get("client")
- elseif mode == "api" then
- get("server")
- end
- if not silent then
- print("Done!")
- if mode == "full" then
- print("Type 'mmtp_files/client' to start the client")
- end
- end
- end
- arg = { ... }
- if arg[2] == "true" then
- silent = true
- else
- silent = false
- end
- if #arg < 1 or #arg > 2 then
- usage()
- elseif arg[1] == "full" then
- download("full")
- elseif arg[1] == "api" then
- download("api")
- else
- usage()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement