diff --git a/debug-cli/cli.js b/debug-cli/cli.js new file mode 100755 index 00000000..cecce270 --- /dev/null +++ b/debug-cli/cli.js @@ -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) diff --git a/debug-cli/package.json b/debug-cli/package.json new file mode 100644 index 00000000..67f1faaf --- /dev/null +++ b/debug-cli/package.json @@ -0,0 +1,14 @@ +{ + "private": true, + "name": "debug-cli", + "version": "1.0.0", + "bin": { + "hafas-client-debug-cli": "./cli.js" + }, + "author": "Jannis R ", + "license": "ISC", + "dependencies": { + "cli-native": "^1.0.0", + "mri": "^1.1.4" + } +}