 debug = require('debug')('s3utils-files-list')
+_ = require 'underscore'
 program = require 'commander'
 Helpers = require '../helpers'
 S3Client = require '../services/s3client'


    s3client = new S3Client loadedCredentials

    Logger.info 'Fetching files...'
    s3client.filteredList {prefix: program.prefix}, program.regex
    .then (files) -> Logger.data 'Matched files', files: files
  else
    Logger.error 'Missing required arguments'
    program.help()

.option '-c, --credentials <path>', 'set s3 credentials file path'
.option '-p, --prefix <name>', 'all files matching the prefix will be loaded'
.option '-r, --regex [name]', 'an optional RegExp used for filtering listed files (e.g.: /(.*)\.jpg/)', ''
.option '--count', 'whether to get the total count of the files or the printed list of them', false
.option '-l, --logFile <path>', 'optionally log to a file instead of printing to console (errors will still be printed to stderr)'
.parse process.argv

