add debug CLI

This commit is contained in:
Jannis R 2019-07-02 20:50:33 +02:00 committed by Jannis Redmann
parent 2e88e964bb
commit 036d0cdca8
2 changed files with 40 additions and 0 deletions

26
debug-cli/cli.js Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env node
'use strict'
const mri = require('mri')
const {join} = require('path')
const {to: fromCli} = require('cli-native')
const createClient = require('..')
const showError = (err) => {
console.error(err)
process.exit(1)
}
const argv = mri(process.argv.slice(2))
const profile = require(join('../p', argv._[0]))
const client = createClient(profile, 'hafas-client debug CLI')
const fn = client[argv._[1]]
const args = argv._.slice(2).map(arg => fromCli(arg))
fn(...args)
.then((res) => {
process.stdout.write(JSON.stringify(res) + '\n')
})
.catch(showError)

14
debug-cli/package.json Normal file
View file

@ -0,0 +1,14 @@
{
"private": true,
"name": "debug-cli",
"version": "1.0.0",
"bin": {
"hafas-client-debug-cli": "./cli.js"
},
"author": "Jannis R <mail@jannisr.de>",
"license": "ISC",
"dependencies": {
"cli-native": "^1.0.0",
"mri": "^1.1.4"
}
}