shell-arguments v1.2.3
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: true, test: true}
If you want apply false, use
node app.js -b=false --test="false"
=> {b: false, test: false}
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'}
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago