Skip to content

Commit

Permalink
feat: add a month flag
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLitt committed Dec 17, 2019
1 parent b5ce577 commit 452535b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"dependencies": {
"csv-writer": "1.2.0",
"meow": "^4.0.0",
"month-before-after": "^1.0.0",
"persistent-cache": "^1.1.1"
},
"devDependencies": {
Expand Down
16 changes: 13 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'use strict'

const meow = require('meow')
const monthBeforeAfter = require('month-before-after')
const main = require('./index')
const done = require('./graphql').done
const cache = require('./graphql').cache
Expand All @@ -14,7 +15,7 @@ const cli = meow(`
-t, --token - GitHub auth token to use
-a, --after - Get contributions after date
-b, --before - Get contributions before data
-m, --month - Get contributions for a certain month this year (format: 'january')
-o, --org - Search all repos within this organisation
-r, --repo - Repository to search
-u, --user - User to which repository belongs
Expand Down Expand Up @@ -81,14 +82,23 @@ const cli = meow(`
verbose: {
type: 'boolean',
alias: 'v'
},
month: {
type: 'string',
alias: 'm'
}
}
})

const token = cli.flags.t || process.env.GITHUB_TOKEN

const after = cli.flags.a ? new Date(cli.flags.a) : new Date(0)
const before = cli.flags.b ? new Date(cli.flags.b) : new Date()
let after = cli.flags.a ? new Date(cli.flags.a) : new Date(0)
let before = cli.flags.b ? new Date(cli.flags.b) : new Date()

if (cli.flags.m) {
after = monthBeforeAfter(cli.flags.m).after
before = monthBeforeAfter(cli.flags.m).before
}

if (cli.flags.wipeCache) {
if (cli.flags.v) {
Expand Down

0 comments on commit 452535b

Please sign in to comment.