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 #!/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,

View file

@ -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"
} }
} }