Created
February 5, 2013 03:42
-
-
Save seriallos/4711976 to your computer and use it in GitHub Desktop.
ComputerCraft program to download gists as programs. Yo dawg.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local tArgs = { ... } | |
if (#tArgs ~= 3) then | |
print( "USAGE: gist get GIST_ID PROGRAM_NAME" ) | |
return | |
end | |
local action = tArgs[1] | |
local gist_id = tArgs[2] | |
local program = tArgs[3] | |
if "get" ~= action then | |
print( "Only 'get' is supported right now" ) | |
return | |
end | |
if fs.exists( program ) then | |
print( "File "..program.." already exists. No action taken" ) | |
return | |
end | |
-- TODO: maybe handle multifile gists? | |
local gist_url = "https://gist.github.com/raw/" .. gist_id | |
local request = http.get( gist_url ) | |
local response = request.readAll() | |
request.close() | |
local file = fs.open( program, "w" ) | |
file.write( response ) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment