vamtiger-argv
v1.2.6
Published
This contains convenience methods for accessing commandline arguments.
Downloads
257
Maintainers
Readme
VAMTIGER Argv
This defines a class for conveniently accessing command-line arguments.
Installation
VAMTIGER Argv can be installed using npm or yarn:
npm i --save vamtiger-argv
or
yarn add vamtiger-argv
Usage
Import or require a referece to VAMTIGER Argv:
import Args = require('vamtiger-argv');
or
const Args = require('vamtiger-argv');
Any Node.js script can be executed with commandline arguments.
node someNodeProgram.js --someArgument someValue --anotherArg anotherValue1 --anotherArg anotherValue2
Commandline arguments can then be referenced by name using the get method.
const args = new Args();
args.get('someArgument'); // someValue
args.getAll('anotherArg'); // ['anotherValue1', 'anotherValue2']
The first argument be referenced by using the first method.
argv.first(); // --someArgument
Raw commandline arguments can also be referenced by using the next method.
args.next('--someArgument'); // someValue
The has method can be used to check whether a commandline arguments is present.
args.has('someArgument'); // true
args.has('--someArgument'); // true
args.has('someValue'); // true
args.has('someOtherArgument'); // false