mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-04-20 23:23:56 +03:00
tools/endpoint-hci-version: mri -> util.parseArgs
This commit is contained in:
parent
f45842d7a3
commit
1e3cbc09a1
2 changed files with 23 additions and 11 deletions
|
@ -1,16 +1,27 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import mri from 'mri'
|
import {parseArgs} from 'node:util'
|
||||||
import {createClient} from '../../index.js'
|
import {createClient} from '../../index.js'
|
||||||
|
|
||||||
const argv = mri(process.argv.slice(2), {
|
const {
|
||||||
boolean: [
|
values: flags,
|
||||||
'help', 'h',
|
positionals: args,
|
||||||
'silent', 's',
|
} = parseArgs({
|
||||||
]
|
options: {
|
||||||
|
help: {
|
||||||
|
type: 'boolean',
|
||||||
|
short: 'h',
|
||||||
|
},
|
||||||
|
silent: {
|
||||||
|
type: 'boolean',
|
||||||
|
short: 's',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
strict: true,
|
||||||
|
allowPositionals: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (argv.help || argv.h) {
|
if (flags.help) {
|
||||||
process.stdout.write(`
|
process.stdout.write(`
|
||||||
Usage:
|
Usage:
|
||||||
endpoint-hci-version <profile>
|
endpoint-hci-version <profile>
|
||||||
|
@ -23,10 +34,11 @@ Examples:
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const silent = argv.silent || argv.s
|
const profileName = args[0]
|
||||||
|
const silent = flags.silent
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
const {profile} = await import(`../../p/${argv._[0]}/index.js`)
|
const {profile} = await import(`../../p/${profileName}/index.js`)
|
||||||
|
|
||||||
const client = createClient(
|
const client = createClient(
|
||||||
profile,
|
profile,
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
"author": "Jannis R <mail@jannisr.de>",
|
"author": "Jannis R <mail@jannisr.de>",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"engines": {
|
||||||
"mri": "^1.1.4"
|
"node": ">=16.17"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue