Advertisement
vanhouc

bootstrapper

Sep 15th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. args = {...}
  2. if #args < 2 then
  3.     term.clear()
  4.     print("Usages:")
  5.     print("gpm [-i] [-r] <program name>")
  6.     shell.exit()
  7. end
  8.  
  9. argsHandler = {}
  10. argsHandler["-i"] = Install
  11. argsHandler["-r"] = Run
  12. for index,value in pairs(args) do
  13.     if (argsHandler[value]) then
  14.         argsHandler[value](args[#args])
  15.     end
  16. end
  17. function Install(programName)
  18.     shell.run("rm "..programName)
  19.     site = http.get("https://raw.githubusercontent.com/vanhouc/computer-craft/master/" .. programName .. ".lua")
  20.     if (site) then
  21.         file = fs.open(programName, "w")
  22.         if (file) then
  23.             file.write(site.readAll())
  24.             file.close()
  25.             print("Successfully updated " .. programName)
  26.         end
  27.     else
  28.         print("failed to load site")
  29.     end
  30. end
  31. function Run(programName)
  32.     shell.run(programName)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement