|
1 | 1 | const yargs = require('yargs')
|
2 | 2 | const request = require('request')
|
3 | 3 | const fs = require('fs');
|
4 |
| -host = "http://localhost:3000"; |
5 |
| -//host = "http://18.233.168.151:80"; |
6 |
| -path = "/Users/bogdanabaev/RandomProgramming/node/notes/CLI/" |
| 4 | +//host = "http://localhost:3000"; |
| 5 | +host = "http://18.233.168.151:80"; |
| 6 | +path = "/Users/bogdanabaev/RandomProgramming/node/notes/CLI/"; |
7 | 7 |
|
8 | 8 |
|
9 | 9 | // BUG: BREAKS WITH SIGNUP CAUSE THERE IS NO 'TIME' AFTER DATA
|
10 | 10 | //BUG: breaks when send request with nonexisting user name
|
| 11 | + |
| 12 | +// lambda - entry point. There construct query, send it to server from there. |
11 | 13 | const sendQuery = function (query, username, signup) {
|
12 | 14 | if (username) {
|
13 | 15 | request.post({
|
@@ -212,16 +214,14 @@ yargs.command({
|
212 | 214 | if (err) {
|
213 | 215 | console.log(err);
|
214 | 216 | } else {
|
215 |
| - console.log(result.body); |
216 | 217 | const dict = JSON.parse(result.body).data.time.report;
|
217 | 218 | for (var project in dict) {
|
218 |
| - console.log(project); |
219 | 219 | console.log("\nProject: " + dict[project]._id);
|
220 | 220 | var minSpent = dict[project].timeSpent;
|
221 | 221 | var hr = parseInt(minSpent / 60);
|
222 | 222 | var min = minSpent % 60;
|
223 | 223 | console.log(`Total time: ${hr}:${min}`);
|
224 |
| - console.log("Work sessions:\n") |
| 224 | + console.log("Work sessions:\n"); |
225 | 225 | dict[project].workSessions.forEach(session => {
|
226 | 226 | console.log(`Start:${session.start.day}/${session.start.month} at ${session.start.time}`);
|
227 | 227 | console.log(session.finish ? `Finish:${session.finish.day}/${session.finish.month} at ${session.finish.time}` : "In progress");
|
@@ -249,7 +249,6 @@ yargs.command({
|
249 | 249 | if (res) {
|
250 | 250 | fs.writeFileSync(path + '.username.txt', argv.username);
|
251 | 251 | }
|
252 |
| - |
253 | 252 | }
|
254 | 253 | });
|
255 | 254 |
|
|
0 commit comments