 initialDir = process.cwd()
 $ = fileName = null
 len = completed = 0
+log        = console.log.bind   console, '\x1b[32m  '
+logErr     = console.error.bind console, '\x1b[31m  '
 
 
 init = ->
   if args.length <= 2
-    console.log '\x1b[31m' + 'please pass an html file' + '\x1b[0m'
+    logErr 'please pass an html file'
     process.exit 1
 
   filePath = args[2]


  fs.readFile fileName, (err, data) ->
    if err
      console.log '\x1b[31m' + 'cannot read `' + filePath + '`\x1b[0m'
      process.exit 1

    $ = cheerio.load data
    targets = $ '.monocat'
    len = targets.length
    if len is 0
      console.log '\x1b[31m' + 'found no elements with `monocat` class... exiting.' + '\x1b[0m'
      process.exit 1

    console.log '\x1b[33m' + 'gathering assets...' + '\x1b[0m'

    targets.each (i, el) ->
      $el = $ el


  fs.writeFile outputFile, $.html(), (err) ->
    if err
      logErr "cannot write to `#{ outputFile }`"
      process.exit 1

    log "output to `#{ outputFile }`"


init()
