+###!
+ * nBuild
+ * Copyright(c) 2011-2012 vol4ok <admin@vol4ok.net>
+ * MIT Licensed
+###
+
+###* Module dependencies ###
+
 require 'colors'
 fs           = require 'fs'
 _            = require 'underscore'

  ['-e', '--environment [ARG]', 'set environment']
  ['-v', '--verbose',           'verbose output']
  ['-V', '--version',           'show version']
  ['-h', '--help',              'display this help message']
]

main = () ->
  optParser  = new OptionParser SWITCHES, BANNER
  o = optParser.parse process.argv[2..]
  
  if o.help
    printLine optParser.help() 
    return
    
  if o.version
    printLine "nbuild v#{VERSION}"
    return
  
  configFiles = []

      break
      
  if configFiles.length is 0
    console.log "Config wasn't found, read the help for more information `nbuild -h`".yellow
    return
    
  if o.arguments.length is 0
    console.log "Command is not specified, read the help for more information `nbuild -h`".yellow
    return
    
  builderOptions = {}
  builderOptions.verbose     = o.verbose if o.verbose
  builderOptions.environment = o.environment if o.environment
  builderOptions.plugins     = o.plugins of o.plugins
  builderOptions.configFiles = configFiles
  
  try
    builder = new Builder(builderOptions)
    builder.exec(cmd) for cmd in o.arguments
  catch err
    console.log "#{err}".red
    
main()
