cli-parameter-getter

1.0.9 • Public • Published

cli-parameter-getter Node.js CI

https://www.npmjs.com/package/cli-parameter-getter https://img.shields.io/npm/dt/cli-parameter-getter.svg

From CLI you can get any parameter from it order or parameter name. Node.js version >= 6

npm install cli-parameter-getter

Examples

Get a parameter from it order

  • You can use this:
node index.js 1337
  • Implementing this way:
const cliParameters = require('cli-parameter-getter').get()
 
const portParameter = cliParameters[0]
console.log(portParameter)
// { name: '1337', value: '1337' } 

Get a parameter from it name or order

  • You can use this:
node index.js port=1337
  • Implementing this way:
const cliParameters = require('cli-parameter-getter').get()
 
const port = cliParameters.port
console.log(port)
// 1337 
 
const portParameter = cliParameters[0]
console.log(portParameter)
// { name: 'port', value: '1337' }

Get a parameter from mixed situations

  • You can use this:
node index.js port=1337 app-test
  • Implementing this way:
const cliParameters = require('cli-parameter-getter').get()
 
const port = cliParameters.port
console.log(port)
// 1337 
 
const portParameter = cliParameters[0]
console.log(portParameter)
// { name: 'port', value: '1337' } 
 
const nameParameter = cliParameters[1]
console.log(nameParameter)
// { name: 'app-test', value: 'app-test' }

You can test the package:

How to dev

  • Releases
npx release-it

Readme

Keywords

none

Package Sidebar

Install

npm i cli-parameter-getter

Weekly Downloads

7

Version

1.0.9

License

ISC

Unpacked Size

13.6 kB

Total Files

6

Last publish

Collaborators

  • jotafeldmann