node-cli-params
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Node Cli Params

Get your inline parameters in a node environment.

Options

Methods Arguments Description
hasKey key hasKey(key) - true or false
getKey key getKey(key) - returns the value of a found key or false

Example

let nodeCliParams = require('node-cli-params');
 
console.log("##################");
console.log("### Parameters ###");
console.log("##################");
console.log(nodeCliParams.parameters);
 
console.log("\r\n#######################");
console.log("### Arguments found ###");
console.log("#######################");
console.log(Object.keys(nodeCliParams.parameters));
 
console.log("\r\nHas 'environment' key ?",nodeCliParams.hasKey('environment'));
console.log("'environment' value =",nodeCliParams.getKey('environment'));

Run

node ./YOUR_FILE_WITH_THE_ABOVE_CODE.js environment=production title="node cli params" metadata="{text: 'normal text'}"

Output:

##################
### Parameters ###
##################
{ 'which node': '',
  'script file path': '',
  environment: 'production',
  title: 'node cli params',
  metadata: '{text: \'normal text\'}' }

#######################
### Arguments found ###
#######################
[ 'which node',
  'script file path',
  'environment',
  'title',
  'metadata' ]

Has 'environment' key ? true
'environment' value = production

Package Sidebar

Install

npm i node-cli-params

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • darklightcode