Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 767 Bytes

README.md

File metadata and controls

48 lines (39 loc) · 767 Bytes

nanoparse

A tiny (1kb!) argument parser. No fluff!

import nanoparse from 'nanoparse'

const argv = nanoparse(process.argv.slice(2));
console.log(argv)
$ node test.js -a beep -b boop
{ flags: { a: 'beep', b: 'boop' }, _: [], extras: [] }
$ node test.js -h 3 -w 4 -abc --beep=boop foo bar baz -xyz=2 --no-that --why because -- --no more -parse
{
  flags: {
    h: 3,
    w: 4,
    a: true,
    b: true,
    c: true,
    beep: 'boop',
    z: 2,
    x: true,
    y: true,
    that: false,
    why: 'because'
  },
  _: [ 'foo', 'bar', 'baz' ],
  extras: [ '--no', 'more', '-parse' ]
}

Too low-level? There's a framework coming up!

Install

$ npm install nanoparse

Note: This package is pure ESM

License

MIT