 cli                 = require 'cli'
+sys                 = require 'sys'
 
 { htmlResponse }    = require '../src/http_utils'
 renderer            = require '../src/renderer'

            url = url.substring(0, url.length - 1)

        getGist url, (data, github_response) ->
            if github_response.statusCode is 200 and validGist(data.files)
                content = renderer
                    style       : data.files['style.styl'].content
                    script      : data.files['script.coffee'].content

getGist = (url, cb) ->
    GIST_API = 'https://api.github.com/gists'
    post_req = rest.get(GIST_API + url)
    post_req.on 'error', (err, response) ->
        sys.puts('getGist error:')
        sys.puts(err)
        sys.puts(response)
    post_req.on 'complete', (data, response) ->
        cb(data, response)

