Skip to content

Commit 42db207

Browse files
committed
feat: cli tool done
need to be tested on project
1 parent b8673df commit 42db207

File tree

5 files changed

+258
-3651
lines changed

5 files changed

+258
-3651
lines changed

app.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

cli.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env node
2+
3+
const yargs = require("yargs/yargs");
4+
const { hideBin } = require("yargs/helpers");
5+
6+
const singleUser = require('./cli/singleUser/index')
7+
8+
const argv = yargs(hideBin(process.argv)).argv;
9+
10+
if (argv.userMail) {
11+
singleUser();
12+
return;
13+
}
14+
15+
console.error("--usermail param is required");

cli/singleUser/index.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const { exec } = require("child_process");
2+
const moment = require("moment");
3+
4+
const yargs = require("yargs/yargs");
5+
const { hideBin } = require("yargs/helpers");
6+
7+
const singleUser = () => {
8+
const argv = yargs(hideBin(process.argv)).argv;
9+
10+
const userEmail = argv.userMail;
11+
12+
console.log(`User email: ${argv.userMail}`);
13+
14+
let todayDate = new Date();
15+
16+
let startingDate = new Date();
17+
startingDate.setDate(todayDate.getDate() - todayDate.getDay());
18+
19+
startingDate.setDate(startingDate.getDate() - 1);
20+
21+
let limitDate = new Date();
22+
limitDate.setDate(startingDate.getDate() + 1);
23+
24+
console.log(todayDate, startingDate);
25+
26+
while (todayDate.getDate() !== startingDate.getDate()) {
27+
const startingDateFormat = moment(startingDate).format("YYYY-M-D");
28+
const limitDateFormat = moment(limitDate).format("YYYY-M-D");
29+
30+
console.log(`Task List ${startingDateFormat} \n`);
31+
32+
const gitCommand = `git log --pretty=format:'%s' --author="${userEmail}" --after="${startingDateFormat}" --before="${limitDateFormat}"`;
33+
34+
exec(gitCommand, (err, stdout, stderr) => {
35+
const commitMsg = stdout.split(" ").slice(1).join(" ");
36+
37+
console.log(commitMsg);
38+
});
39+
40+
startingDate.setDate(startingDate.getDate() + 1);
41+
42+
limitDate.setDate(startingDate.getDate() + 1);
43+
}
44+
};
45+
46+
module.exports = singleUser;

0 commit comments

Comments
 (0)