minimisty

1.1.1 • Public • Published

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 the a flag was provided is if (args.a === true). If you simply do if (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 -3 -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' }

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    4
    • latest

Version History

Package Sidebar

Install

npm i minimisty

Weekly Downloads

7

Version

1.1.1

License

Fair

Last publish

Collaborators

  • talles