<commit_before>'use strict';

const cli = require('commander');
const path = require('path');
const api = require('./api');

cli
    .version('1.0.0')
    .option('-d, --directory <directory>', 'Specify a directory')
    .option('-o, --output <directory>', 'Output directory')
    .option('-r, --recurse', 'Generate statistics recursively')
    .option('-y, --year <year>', 'Get the commits for the specified year')
    .parse(process.argv);

let options = {};

if (cli.directory) {
    options.directory = cli.directory;
}

if (cli.year) {
    options.year = cli.year;
}

let repositoryPath = cli.output;
let isRecursive = cli.recurse;

api.createRepository(repositoryPath).then((didCreateRepo) => {
    let directories = [];

    return api.findRepositories(options.directory);
}).then((repositories) => {
    let promises = repositories.map((repository) => {
        return api.countCommits({
            directory: path.join(options.directory, repository),
            year: cli.year
        });
    });

    return Promise.all(promises);
}).then((commits) => {
    console.log(commits)
}).catch((err) => {
    console.log(err);
});
<commit_msg>Add author flag<commit_after>'use strict';

const cli = require('commander');
const path = require('path');
const api = require('./api');

cli
    .version('1.0.0')
    .option('-d, --directory <directory>', 'Specify a directory')
    .option('-o, --output <directory>', 'Output directory')
    .option('-r, --recurse', 'Generate statistics recursively')
    .option('-a, --author <author>', 'Get the commits by the specified author.')
    .option('-y, --year <year>', 'Get the commits for the specified year')
    .parse(process.argv);

let options = {};

if (cli.directory) {
    options.directory = cli.directory;
}

let repositoryPath = cli.output;
let isRecursive = cli.recurse;

api.createRepository(repositoryPath).then((didCreateRepo) => {
    let directories = [];

    return api.findRepositories(options.directory);
}).then((repositories) => {
    let promises = repositories.map((repository) => {
        return api.countCommits({
            directory: path.join(options.directory, repository),
            year: cli.year,
            author: cli.author
        });
    });

    return Promise.all(promises);
}).then((commits) => {
    console.log(commits)
}).catch((err) => {
    console.log(err);
});

{'fraction_non_alphanumeric': 0.17801268498942918, 'fraction_numerical': 0.002536997885835095, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 20, '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': '2670830', 'n_tokens_mistral': 742, 'n_tokens_neox': 735, 'n_words': 166}