Skip to content

Commit 001ba60

Browse files
committed
add date shorthands. close kriskbx#48
1 parent 518e7e9 commit 001ba60

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

readme.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ![gtt](https://raw.githubusercontent.com/kriskbx/gitlab-time-tracker/master/preview/icon.png) gtt
1+
/home/kriskbx/data/Keys/ssh/github_rsa"# ![gtt](https://raw.githubusercontent.com/kriskbx/gitlab-time-tracker/master/preview/icon.png) gtt
22

33
[![npm](https://img.shields.io/npm/dt/gitlab-time-tracker.svg?style=flat-square)](https://www.npmjs.com/package/gitlab-time-tracker)
44
[![npm](https://img.shields.io/npm/v/gitlab-time-tracker.svg?style=flat-square)](https://www.npmjs.com/package/gitlab-time-tracker)
@@ -314,6 +314,14 @@ gtt report --from="2017-03-01" --to="2017-04-01"
314314

315315
*Note: `--from` defaults to 1970-01-01, `--to` defaults to now. Make sure to use an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) compatible time/date format.*
316316

317+
There are some quick shorthands:
318+
319+
```shell
320+
gtt report --today
321+
gtt report --this_week
322+
gtt report --this_month
323+
```
324+
317325
#### Include closed issues/merge requests
318326

319327
```shell

src/gtt-report.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ program
3030
.arguments('[project] [ids]')
3131
.option('-f --from <from>', 'query times that are equal or greater than the given date')
3232
.option('-t --to <to>', 'query times that are equal or smaller than the given date')
33+
.option('--today', 'ignores --from and --to and queries entries for today')
34+
.option('--this_week', 'ignores --from and --to and queries entries for this week')
35+
.option('--this_month', 'ignores --from and --to and queries entries for this month')
3336
.option('-c --closed', 'include closed issues')
3437
.option('-u --user <user>', 'only query times from the given user')
3538
.option('-m --milestone <milestone>', 'include issues from the given milestone')
@@ -110,6 +113,20 @@ config
110113
.set('_checkToken', program.check_token)
111114
.set('_createDump', program.output === 'dump');
112115

116+
// date shortcuts
117+
if(program.today)
118+
config
119+
.set('from', moment().startOf('day'))
120+
.set('to', moment().endOf('day'));
121+
if(program.this_week)
122+
config
123+
.set('from', moment().startOf('week'))
124+
.set('to', moment().endOf('week'));
125+
if(program.this_month)
126+
config
127+
.set('from', moment().startOf('month'))
128+
.set('to', moment().endOf('month'));
129+
113130
Cli.quiet = config.get('quiet');
114131
Cli.verbose = config.get('_verbose');
115132

0 commit comments

Comments
 (0)