Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
/ pr-police Public archive

Commit

Permalink
feat: add cli to server
Browse files Browse the repository at this point in the history
This enables users to run the bot via terminal command.
  • Loading branch information
rogeriopvl committed May 11, 2017
1 parent a614def commit 703820b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions bin/pr-police
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

const minimist = require('minimist')

require('../lib/cli')(minimist(process.argv.slice(2)))
27 changes: 27 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const server = require('./server')
const meta = require('../package.json')

module.exports = function (args) {
if (args.help) {
showUsage()
process.exit(0)
} else if (args.version) {
showVersion()
process.exit(0)
} else if (args._.length > 0) {
showUsage()
process.exit(-1)
} else {
server()
}
}

function showUsage () {
console.log(meta.name + ' [--version] [--help]\n')
console.log('\t--version show version info')
console.log('\t--help show this usage info')
}

function showVersion () {
console.log(meta.name + ' version ' + meta.version)
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
"github",
"labels"
],
"bin": {
"pr-police": "./bin/pr-police"
},
"author": "rogeriopvl",
"license": "MIT",
"dependencies": {
"minimist": "^1.2.0",
"pullhub": "^1.0.1",
"slackbots": "^1.0.2"
},
Expand Down
6 changes: 1 addition & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,6 @@ lodash.cond@^4.3.0:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"

lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"

lodash.flatten@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
Expand Down Expand Up @@ -1047,7 +1043,7 @@ minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"

minimist@^1.1.0, minimist@~1.2.0:
minimist@^1.1.0, minimist@^1.2.0, minimist@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

Expand Down

0 comments on commit 703820b

Please sign in to comment.