Last active
August 1, 2016 17:00
-
-
Save mightystoosh/025611d7ae548e24e51e36444f573a39 to your computer and use it in GitHub Desktop.
turtle gist
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