node-argv-to-object

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i node-argv-to-object

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

2.67 kB

Total Files

4

Last publish

Collaborators

  • indaam