mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
26 lines
579 B
JavaScript
Executable file
26 lines
579 B
JavaScript
Executable file
#!/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)
|