nzcli is a class for checking parameters entered in the terminal for nzserver
Table of Contents
nzcli
reads key="value"
arguments entered into the terminal when the program is started, and creates an object with those parameters.Install nzcli using npm:
npm install nzcli
And import it as a CommonJS module:
const nzcli = require('nzcli');
In this example, when creating a new class nzcli
, the global variable parameters
and process
are passed. The class will create a reference to the variable parameters
and add the arguments found with values to this variable. If you do not pass the global variable, the arguments will be written to its own variable parameters
.
const nzcli = require('./index.js');
const process = require('process');
const parameters = {}; // global variable
const cli = new nzcli(parameters, process);
console.log(parameters);
//console.log('or');
//console.log(cli.parameters);
Now when you enter the command in the terminal:
$ node test.js config="/home/user/dir/" db="/home/user/dir/DB/" net="network" host="192.168.0.10" port="8080" user="User Name" mail="username@somemail.com"
We will get the output of the object with parameters:
{
config: '/home/user/dir/',
db: '/home/user/dir/DB/',
net: 'network',
host: '192.168.0.10',
port: '8080',
user: 'User Name',
mail: 'username@somemail.com'
}
GNU Lesser General Public License (3.0 or any later version). Please take a look at the LICENSE file for more information.