<commit_before>#!/usr/bin/env node

var _ = require('lodash');
var async = require('async');

var utils = require('../../utils');

var actions = utils.getActions();

function registerCommand(program) {
	program
		.command('user [quantity]')
		.alias('u')
		.description('Adds one or more users to the database.')
		.action(function(number) {
			number = !_.isNaN(Number(number)) ? Number(number) : 1;
			addUser(number);
		});

	return program;
}

function addUser(numberOfUsers, callback) {
	var users = [];
	var bar = utils.getProgressBar(numberOfUsers);

	utils.statusMessage(numberOfUsers, 'user');

	async.timesSeries(
		numberOfUsers,
		function(n, asyncCallback) {
			var person = utils.generateUserInfo();

			actions.addUser(
				person.firstName,
				person.lastName,
				person.screenName,
				person.emailAddress,
				function(error, response) {
					if (!error) {
						bar.tick();
						asyncCallback(null, response);
					}
				}
			);
		},
		function(error, results) {
			if (!error) {
				for (var i = 0, length = results.length; i < length; i++) {
					console.log('');
					console.log('New User:');
					utils.printJSON(JSON.parse(results[i]));
					console.log('');
				}

				console.log('Successfully added', + results.length + ' new users.');

				if (callback) {
					callback(null, results);
				}
			}
		}
	);

	return users;
}

module.exports.registerCommand = registerCommand;
module.exports.command = addUser;<commit_msg>Add user command only logs through callback<commit_after>#!/usr/bin/env node

var _ = require('lodash');
var async = require('async');

var utils = require('../../utils');

var actions = utils.getActions();

function registerCommand(program) {
	program
		.command('user [quantity]')
		.alias('u')
		.description('Adds one or more users to the database.')
		.action(function(number) {
			number = !_.isNaN(Number(number)) ? Number(number) : 1;
			addUser(number, function(error, results) {
				if (!error) {
					for (var i = 0, length = results.length; i < length; i++) {
						console.log('');
						console.log('New User:');
						utils.printJSON(JSON.parse(results[i]));
						console.log('');
					}

					console.log('Successfully added', + results.length + ' new users.');
				}
			});
		});

	return program;
}

function addUser(numberOfUsers, callback) {
	var users = [];
	var bar = utils.getProgressBar(numberOfUsers);

	utils.statusMessage(numberOfUsers, 'user');

	async.timesSeries(
		numberOfUsers,
		function(n, asyncCallback) {
			var person = utils.generateUserInfo();

			actions.addUser(
				person.firstName,
				person.lastName,
				person.screenName,
				person.emailAddress,
				function(error, response) {
					if (!error) {
						bar.tick();
						asyncCallback(null, response);
					}
				}
			);
		},
		function(error, results) {
			if (!error && callback) {
				callback(null, results);
			}
		}
	);

	return users;
}

module.exports.registerCommand = registerCommand;
module.exports.command = addUser;
{'fraction_non_alphanumeric': 0.15805369127516777, 'fraction_numerical': 0.0013422818791946308, 'mean_word_length': 3.3773861967694567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3273834', 'n_tokens_mistral': 1164, 'n_tokens_neox': 951, 'n_words': 202}