tools/endpoint-hci-version: mri -> util.parseArgs

This commit is contained in:
Jannis R 2023-04-25 00:38:41 +02:00
parent f45842d7a3
commit 1e3cbc09a1
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 23 additions and 11 deletions

View file

@ -1,16 +1,27 @@
#!/usr/bin/env node
import mri from 'mri'
import {parseArgs} from 'node:util'
import {createClient} from '../../index.js'
const argv = mri(process.argv.slice(2), {
boolean: [
'help', 'h',
'silent', 's',
]
const {
values: flags,
positionals: args,
} = 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(`
Usage:
endpoint-hci-version <profile>
@ -23,10 +34,11 @@ Examples:
process.exit(0)
}
const silent = argv.silent || argv.s
const profileName = args[0]
const silent = flags.silent
;(async () => {
const {profile} = await import(`../../p/${argv._[0]}/index.js`)
const {profile} = await import(`../../p/${profileName}/index.js`)
const client = createClient(
profile,

View file

@ -8,7 +8,7 @@
},
"author": "Jannis R <mail@jannisr.de>",
"license": "ISC",
"dependencies": {
"mri": "^1.1.4"
"engines": {
"node": ">=16.17"
}
}