Skip to content

Commit 2afcbf9

Browse files
committed
Add status command
1 parent 5236920 commit 2afcbf9

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

gtt-status.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const program = require('commander');
2+
const colors = require('colors');
3+
const moment = require('moment');
4+
5+
const Frame = require('./models/frame');
6+
const Config = require('./include/file-config');
7+
const Cli = require('./include/cli');
8+
const Fs = require('./include/filesystem');
9+
10+
program.parse(process.argv);
11+
12+
let config = new Config(__dirname);
13+
14+
Fs.find(`"stop": false`, config.frameDir)
15+
.then(frames => {
16+
if (frames.length === 0) {
17+
console.log('No projects are started right now.');
18+
return;
19+
}
20+
21+
frames.forEach(file => {
22+
let frame = Frame.fromFile(config, file);
23+
console.log(`Project ${frame.project.magenta} ${frame.resource.type.blue} ${('#' + frame.resource.id).blue} is running, started ${moment(frame.start).fromNow().green} (id: ${frame.id})`);
24+
});
25+
})
26+
.catch(error => Cli.error('Could not read frames.', error));

gtt.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env node
22

3-
const version = '1.1.2';
3+
const version = '1.1.3';
44
const program = require('commander');
55

66
program
77
.version(version)
88
.command('start [project] [id]', 'start monitoring time for the given project and resource id')
9+
.command('status', 'shows if time monitoring is running')
910
.command('stop', 'stop monitoring time')
1011
.command('cancel', 'cancel and discard active monitoring time')
1112
.command('log', 'log recorded time records')

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gitlab-time-tracker",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "A CLI that makes working with GitLabs time tracking feature more enjoyable",
55
"main": "gtt.js",
66
"scripts": {},

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ you can sync time records to GitLab and create "time spent comments" automatical
5555
gtt start "kriskbx/example-project" 15
5656
gtt start 15
5757
58+
# status
59+
gtt status
60+
5861
# stop LOCAL time monitoring
5962
gtt stop
6063

0 commit comments

Comments
 (0)