node-argv-to-object
Simple converter node argv to json object
Install
npm install node-argv-to-object
or yarn add node-argv-to-object
Usage
const argvToObject = require('node-argv-to-object');
const argvObject = argvToObject();
console.log(argvObject);
or
const argvObject = require('node-argv-to-object')();
console.log(argvObject);
Sample
CLI
node sample.js numb=12 arr=[1,2] obj={\"name\":\"indaam\"} str=string other
OUTPUT
{
argv:
[ '/usr/local/bin/node',
'.../node-argv-to-object/sample.js',
'numb=12',
'arr=[1,2]',
'obj={"name":"ken"}',
'str=string',
'other' ],
node: '/usr/local/bin/node',
numb: 12,
arr: [ 1, 2 ],
obj: { name: 'indaam' },
str: 'string',
other: true // default true
}
License
MIT