argsclopts
cliclopts but for Node.js parseArgs. A library that formats standard usage strings using the node:util
parseArgs
options
object shape with an additional help
field added to it.
npm install argsclopts
Usage
import { formatHelpText, printHelpText } from 'argsclopts'
import { join } from 'node:path'
import { parseArgs } from 'node:util'
const pkgPath = join(import.meta.dirname, 'package.json')
const options = {
foo: {
type: 'boolean',
short: 'f',
help: 'A foo flag thats a boolean'
},
bar: {
type: 'string',
help: 'A bar flag thats a string'
}
}
await printHelpText({
options,
pkgPath
})
const args = ['-f', '--bar', 'b']
const { values } = parseArgs({ args, options })
License
MIT