Advertisement
Guest User

Untitled

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