Closed sarnobat closed 2 years ago
Morning! The follow example works fine for me..
import commandLineArgs from 'command-line-args'
const optionDefinitions = [
{ name: 'num-max', type: Number }
]
const options = commandLineArgs(optionDefinitions)
console.log(options)
Usage:
$ node example.mjs --num-max 2
{ 'num-max': 2 }
Thanks for the quick reply, I'll try this and follow up here if I still have difficulties.
It's common for long options to contain
-
. I can't figure out a way to add a name that contains a dash.I was hoping either
_
gets converted to-
, or that it's possible to specify a destination variable. I believe python's argparse works this way.(Good to see a fellow Welshman btw)