Advertisement
itsjstn

CC: Tweaked - github-get

Nov 28th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | Gaming | 0 0
  1. if #({...}) < 2 then
  2.     print("Usage: github-get <url> <file path>");
  3.     return;
  4. end
  5.  
  6. local url = ...;
  7. local path = select(2, ...);
  8.  
  9. print("Downloading...");
  10. local response = http.get(url);
  11. if response then
  12.     local fileContent = response.readAll();
  13.     response.close();
  14.    
  15.     local file = fs.open(path, "w");
  16.     file.write(fileContent);
  17.     file.close();
  18.    
  19.     print("Saved file as " .. path);
  20. else
  21.     print("Failed to download provided file. Please retry.");
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement