From 2948ecff5fa10d897f21893f0bda2df677dbd402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Mendiara=20Ca=C3=B1ardo?= Date: Thu, 30 Nov 2017 15:34:00 +0100 Subject: [PATCH] add cli support --- cli.js | 14 ++++++++++++++ package.json | 3 +++ 2 files changed, 17 insertions(+) create mode 100755 cli.js diff --git a/cli.js b/cli.js new file mode 100755 index 0000000..aca2b7c --- /dev/null +++ b/cli.js @@ -0,0 +1,14 @@ +#!/usr/bin/env node + +var gh = require('./'); + +if (!process.argv[2]) { + process.stderr.write('Error: URL must be provided as first argument\n'); + process.exit(1); +} +var res = gh(process.argv[2]); +if (res == null) { + process.stderr.write('Error: Invalid parameter: ' + process.argv[2] + '\n'); + process.exit(1); +} +process.stdout.write(JSON.stringify(res, null, 2) + '\n'); diff --git a/package.json b/package.json index 8d9fdcf..bc7bc21 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,9 @@ "files": [ "index.js" ], + "bin": { + "parse-github-url" : "./cli.js" + }, "main": "index.js", "engines": { "node": ">=0.10.0"