forked from ndu2/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgtt-status.js
More file actions
executable file
·35 lines (30 loc) · 1.29 KB
/
gtt-status.js
File metadata and controls
executable file
·35 lines (30 loc) · 1.29 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
35
const program = require('commander');
const colors = require('colors');
const moment = require('moment');
const Config = require('./include/file-config');
const Cli = require('./include/cli');
const Tasks = require('./include/tasks');
program
.option('--verbose', 'show verbose output')
.option('-s', 'short output')
.parse(process.argv);
Cli.verbose = program.opts().verbose;
let config = new Config(__dirname),
tasks = new Tasks(config);
tasks.status()
.then(frames => {
if (frames.length === 0) {
if (program.opts().s) {
console.log('gtt idle ');
}else {
console.log('No projects are started right now.');
}
return;
}
if (program.opts().s) {
frames.forEach(frame => console.log(`${frame.project.magenta} ${frame.resource.type.blue} ${('#' + frame.resource.id).blue} ${moment(frame.start).fromNow().green} (id: ${frame.id})`));
} else {
frames.forEach(frame => console.log(`Project ${frame.project.magenta} ${frame.resource.type.blue} ${('#' + frame.resource.id).blue} ${frame.note?frame.note:''} is running, started ${moment(frame.start).fromNow().green} (id: ${frame.id})`));
}
})
.catch(error => Cli.error('Could not read frames.', error));