1.1.1 • Published 8 years ago
minimisty v1.1.1
minimisty
Minimistish argument parsing.
I have used minimist as my argument-parsing library, but two minor things always bothered me:
Checking for flags is not that good.
-a
becomes{ a: true }
. The correct way to check if thea
flag was provided isif (args.a === true)
. If you simply doif (args.a)
you could be mistakingly interpreting-a some-other-thing
.process.argv.slice(2) isn't really classy. There is a reason for that, but I use it only with node so I don't care.
Usage
// example.js
const argv = require('minimisty')
console.dir(argv)
$ node example.js -a beep -b boop
{ _: [], _flags: {}, a: 'beep', b: 'boop' }
$ node example.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
_flags: { '5': true, n: true, a: true, b: true, c: true },
x: '3',
y: '4',
beep: 'boop' }