{"size": 819, "ext": "js", "max_stars_repo_path": "src/app.js", "max_stars_repo_name": "fleidloff/agile-forecasting", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/app.js", "max_issues_repo_name": "fleidloff/agile-forecasting", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/app.js", "max_forks_repo_name": "fleidloff/agile-forecasting", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.0882352941, "max_line_length": 115, "alphanum_fraction": 0.619047619}
var shapecube = require("shapecube");
var workingDays = require("./workingDays");
var diagram = require("./diagram");
var mdTable = require("./mdTable");
var fs = require("fs");
var input;

try {
    input = require("../projects/" + process.argv[process.argv.length - 1])
} catch(err) {
    console.error("please provide a valid input json file as 1st parameter.");
    process.exit();
}


var resultDays = {};

for(var i = 0; i < input.cycles; i++) {
    var wd = workingDays(input);
    if (!resultDays[wd]) {
        resultDays[wd] = 0;
    }
    resultDays[wd] += 1;
}

var data = mdTable(diagram(resultDays, input));

fs.writeFile("./projects/" + process.argv[process.argv.length - 1] + ".md", data, { flags: 'wx' }, function (err) {
    if (err) throw err;
    console.log("It's saved!");
});

console.log(data);
