diff --git a/bin.js b/bin.js new file mode 100755 index 0000000..23c3820 --- /dev/null +++ b/bin.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +// Call bolt11 decode from the command line. + +const decode = require('./payreq').decode + +const [,, command, invoice] = process.argv + +if (command !== 'decode') { + throw new Error('Invalid command, expected "bolt11 decode "') +} + +const results = decode(invoice) + +console.log(JSON.stringify(results, null, 2)) + diff --git a/package.json b/package.json index 297dd4a..339e1cc 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "test": "npm run standard && npm run coverage", "unit": "tape test/*.js" }, + "bin": { + "bolt11": "./bin.js" + }, "devDependencies": { "nyc": "^15.0.0", "standard": "*",