forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgtt-stop.js
More file actions
executable file
·34 lines (27 loc) · 1.08 KB
/
gtt-stop.js
File metadata and controls
executable file
·34 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {Command} from 'commander';
import colors from 'colors';
import moment from 'moment';
import Config from './include/file-config.js';
import Cli from './include/cli.js';
import Tasks from './include/tasks.js';
function stop() {
const stop = new Command('stop', 'stop monitoring time')
.option('--verbose', 'show verbose output')
.action((options, program) => {
Cli.verbose = program.opts().verbose;
let config = new Config(process.cwd()),
tasks = new Tasks(config);
tasks.stop()
.then(frames => {
frames.forEach(frame => {
if(!frame.resource.new)
return console.log(`Stopping project ${frame.project.magenta} ${frame.resource.type.blue} ${('#' + frame.resource.id).blue}, started ${moment(frame.start).fromNow().green} (id: ${frame.id})`)
console.log(`Stopping project ${frame.project.magenta} for new ${frame.resource.type} "${(frame.resource.id).blue}", started ${moment(frame.start).fromNow().green} (id: ${frame.id})`)
});
})
.catch(error => Cli.error(error));
}
);
return stop;
}
export default stop;