argps

Parsing arguments to Object automatically

Usage no npm install needed!

<script type="module">
  import argps from 'https://cdn.skypack.dev/argps';
</script>

README

argps

Join the chat at https://gitter.im/Jarvin-Guan/argps Build Coverage Status DUB

Aim : Parsing parameters automatically node.js

Prower by Regex

CI Node version Passed

  • 0.12
  • 4
  • 5
  • iojs

Installation

$ npm install argps --save

Demo

$ git clone https://github.com/Jarvin-Guan/argps.git
$ cd argps
$ node ./demo/test.js -a 1 -b 2
    { _: [ '' ], a: '1', b: '2' }
  node ./demo/test.js -a 1 -a 2 -b -c --d --e 4
    { _: [ '' ],a: [ '1', '2' ],b: 'true',c: 'true',d: 'true',e: '4' }
  node ./demo/test.js v d k -a 1 gg dd -b
    { _: [ 'v', 'd', 'k', 'gg', 'dd' ], a: '1', b: 'true' }

How to use in your project?

const argps = require( 'argps');
var argObject = argps(process.argv.slice(2));
/* just like demo #1
  argObject:{
     _: [ '' ],
     a: '1',
     b: '2' }
*/
//argObject.a === '1'

License

MIT