shell-arguments

1.2.3 • Public • Published

Build Status Coverage Status npm version MIT Licence

shell-arguments

This module serialize the arguments passed to the npm, node, nodemon, forever, or pm2, and convert this arguments to json.

Install

npm install --save shell-arguments

and in your .js file

import arguments from 'shell-arguments';
 
console.log(arguments);

now, var arguments, return a object, with your data, example:

node app.js -b --test
=> {b: truetesttrue}

If you want apply false, use

node app.js -b=false --test="false"
=> {b: falsetestfalse}

Note that the string with false value was converted to a boolean false, because this module convert primitive values.

Too accept other values, like below:

node app.js -o '/Desktop/teste' --output="/Desktop/teste"
=> {o: '/Desktop/teste', output: '/Desktop/teste'}

Convert primitive values

node app.js --port 8080 --numbers="2", --allow="false" --private="true"
=> {port: 8080, numbers: 2, allow: false, private: true}

Multiple flags with a single -, example:

node app.js -rpqs
=> {r: true, p: true, q: true, s: true}

Apply value with =, or space:

node app.js --output '/Desktop/test' --config="test"
=> {output: '/Desktop/test', config: 'test'}

Package Sidebar

Install

npm i shell-arguments

Weekly Downloads

18

Version

1.2.3

License

MIT

Last publish

Collaborators

  • darlanmendonca