Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if #({...}) < 2 then
- print("Usage: github-get <raw url> <path>");
- return;
- end
- local url = ...;
- local path = select(2, ...);
- local githubPAT = settings.get("githubPAT");
- print("Downloading...");
- local response;
- if githubPAT ~= nil then
- response = http.get({
- url = url,
- headers = {
- Authorization = "Bearer " .. githubPAT
- }
- });
- else
- response = http.get(url);
- end
- if response then
- local fileContent = response.readAll();
- response.close();
- local file = fs.open(path, "w");
- file.write(fileContent);
- file.close();
- print("Saved as " .. path);
- else
- print("Failed to save provided file. Please try again.");
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement