 
 {join, existsSync} = path
 
-printLine = (line) -> process.stdout.write line + '\n'
-
 VERSION = "0.1"
 BANNER = 'Usage: nbuild [options] command[:step]'
 SWITCHES = [

      break
      
  if configFiles.length is 0
    printLine "Config wasn't found, read the help for more information `nbuild -h`".yellow
    return
    
  if o.arguments.length is 0
    printLine "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.configFiles = configFiles
  
  try
    builder = new Builder(builderOptions)
    builder.exec(cmd) for cmd in o.arguments
  catch err
    console.log printLine("#{err}".red)
    
main()

  ['-e', '--environment [ARG]', 'set environment']
  ['-v', '--verbose',           'verbose output']
  ['-V', '--version',           'show version']
  ['-p', '--plugin [FILE*]'],   'add plugin file or dir']
  ['-h', '--help',              'display this help message']
]

###* Entry point ###

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