       logger: logger
 
   stockimport = new StockImport options
-
-  importFn = (fileName) ->
-    throw new Error 'You must provide a file to be processed' unless fileName
-    d = Q.defer()
-    logger.info "About to process file #{fileName}"
-    mode = stockimport.getMode fileName
-    fs.read fileName
-    .then (content) ->
-      logger.info 'File read, running import'
-      stockimport.run(content, mode)
-      .then (result) ->
-        logger.info stockimport.sumResult(result)
-        d.resolve(fileName)
-      .fail (e) ->
-        logger.error e, "Oops, something went wrong when processing file #{fileName}"
-        d.reject 1
-    .fail (e) ->
-      logger.error e, "Cannot read file #{fileName}"
-      d.reject 2
-    d.promise
 
   file = argv.file
 


process.on 'SIGUSR2', -> logger.reopenFileStreams()

credentialsConfig = ProjectCredentialsConfig.create()
.fail (err) ->
  logger.error e, "Problems on getting client credentials from config files."
.then (credentials) ->
  options =
    config: credentials.enrichCredentials

      targetFolder: argv.sftpTarget
      logger: logger

    sftpHelper.download(TMP_PATH)
    .then (files) ->
      logger.info files, "Processing #{files.length} files..."
