argz-parze

Command line argument parser

Usage no npm install needed!

<script type="module">
  import argzParze from 'https://cdn.skypack.dev/argz-parze';
</script>

README

argz-parze Build Status

Command line argument parser

Install

$ npm install argz-parze

Usage

There is a single function exposed which takes an array, this would be akin to process.argv.slice(2), and returns an object. An underscore key holds arguments provided after a terminating sequence '--' and arguments passed without a hyphen type.

const parse = require('argz-parse')

> parse(['-a', 'hey', '-b', 'foo'])
{ _: [], a: 'hey', b: 'foo' }

> parse(['-abc', 'hi'])
{ _: [], c: 'hi', a: true, b: true }

> parse(['--foo', '--bar=3'])
{ _: [], bar: 3, foo: true }

> parse(['--foo', '--bar=baz', '-mtv', '--', 'hello', 'world'])
{ _: [ 'hello', 'world' ],
bar: 'baz',
foo: true,
m: true,
t: true,
v: true }

License

MIT