<commit_before>var user      = require('../lib/user');
var _         = require('lodash');
var logger    = require('../lib/logger');
var cliUtil   = require('../lib/cli-util');
var sfClient  = require('../lib/sf-client');
var metadata  = require('../lib/metadata');
var async     = require('async');
var Promise   = require('bluebird');
var minimatch = require('minimatch');

function getFilePaths(globs, oauth) {
  return new Promise(function(resolve, reject) {


    async.mapLimit(typeGroups, 5, iterator, function(err, res) {
      if(err) return reject(err);
    });
  });
}

var run = module.exports.run = function(opts, cb) {

  var typeMatches = metadata.getTypesFromGlobs(opts.globs);

  // log out the matched directories
  _.each(typeMatches, function(tm) {
    logger.list(tm.folder);
  });

  // group the metadata into groups of 3 since that's the limit
  // in a single listMetadata call
  var grouped = _.reduce(typeMatches, function(result, tm) {
    if(!result.length || result[result.length-1].length === 3) {
      result.push([tm.name]);
    } else {
      result[result.length-1].push(tm.name);
    }
    return result;
  }, []);

  console.log(grouped);
  process.exit(1);

  sfClient.meta.listMetadata({
    oauth: opts.oauth,
    queries: _.map(typeMatches, function(t) {
      return {
        type: t.name
      };
    })
  }).then(function(res) {
    console.log(res);
    cb();
  }).catch(function(err) {
    console.error(err.root);
    cb(err);
  });

};

module.exports.cli = function(program) {
  program.command('retrieve [globs...]')
    .description('retrieve metadata from target org')
    .option('-o, --org <org>', 'the Salesforce organization to use')
    .option('--meta', 'force retrieve with metadata api')
    .action(function(globs, opts) {
      opts.globs = globs;
      return cliUtil.executeRun(run)(opts);
    });
};<commit_msg>adding untested iterator call to listMetadata<commit_after>var user      = require('../lib/user');
var _         = require('lodash');
var logger    = require('../lib/logger');
var cliUtil   = require('../lib/cli-util');
var sfClient  = require('../lib/sf-client');
var metadata  = require('../lib/metadata');
var async     = require('async');
var Promise   = require('bluebird');
var minimatch = require('minimatch');

function getFilePaths(typeGroups, oauth) {
  return new Promise(function(resolve, reject) {

    var iterator = function(types, cb) {
      sfClient.meta.listMetadata({
        oauth: opts.oauth,
        queries: _.map(types, function(t) {
          return {
            type: t.name
          };
        })
      }).then(function(res) {
        console.log(res);
        cb(null, res);
      }).catch(function(err) {
        console.error(err.root);
        cb(err);
      });
    };

    async.mapLimit(typeGroups, 5, iterator, function(err, res) {
      if(err) return reject(err);
      resolve(res);
    });
  });
}

var run = module.exports.run = function(opts, cb) {

  var typeMatches = metadata.getTypesFromGlobs(opts.globs);

  // log out the matched directories
  _.each(typeMatches, function(tm) {
    logger.list(tm.folder);
  });

  // group the metadata into groups of 3 since that's the limit
  // in a single listMetadata call
  var grouped = _.reduce(typeMatches, function(result, tm) {
    if(!result.length || result[result.length-1].length === 3) {
      result.push([tm.name]);
    } else {
      result[result.length-1].push(tm.name);
    }
    return result;
  }, []);

  process.exit(1);

  getFilePaths(grouped).then(function(paths) {
    console.log(paths);
  }).catch(function(err) {
    cb(err);
  });

};

module.exports.cli = function(program) {
  program.command('retrieve [globs...]')
    .description('retrieve metadata from target org')
    .option('-o, --org <org>', 'the Salesforce organization to use')
    .option('-l, --local-only', 'only retrieve metadata that exists locally')
    .option('-r, --replace', 'replace all local metadata with the retrieved metadata')
    .option('--meta', 'force retrieve with metadata api')
    .action(function(globs, opts) {
      opts.globs = globs;
      return cliUtil.executeRun(run)(opts);
    });
};
{'fraction_non_alphanumeric': 0.1671455938697318, 'fraction_numerical': 0.0028735632183908046, 'mean_word_length': 2.9933078393881454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4360561', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1316, 'n_words': 296}