sollaires

github.lua

Feb 4th, 2013
1,181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1.  
  2. local tArgs = { ... }
  3.  
  4. if (#tArgs ~= 3) then
  5.   print( "USAGE: github get <GITHUB-PATH> <PROGRAM-NAME>" )
  6.   return
  7. end
  8.  
  9. local action = tArgs[1]
  10. local github_path = tArgs[2]
  11. local program = tArgs[3]
  12.  
  13. if "get" ~= action then
  14.   print( "Only 'get' is supported right now" )
  15.   return
  16. end
  17.  
  18. if fs.exists( program ) then
  19.   print( "File "..program.." already exists" )
  20.   return
  21. end
  22.  
  23. local github_url = "https://raw.github.com/"..github_path
  24.  
  25. local request = http.get( github_url )
  26. local response = request.readAll()
  27. request.close()
  28.  
  29. local file = fs.open( program, "w" )
  30. file.write( response )
  31. file.close()
Advertisement
Add Comment
Please, Sign In to add comment