mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
add debug CLI
This commit is contained in:
parent
2e88e964bb
commit
036d0cdca8
2 changed files with 40 additions and 0 deletions
26
debug-cli/cli.js
Executable file
26
debug-cli/cli.js
Executable 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
14
debug-cli/package.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue