get-args
Light arguments parser for Node.js
Installation
You can install get-args using NPM:
$ npm install --save get-args
Usage
var getArgs = ;
arg = getArgs(args)
Returns an object with the result of parsing the array of arguments args
. If no array is provided, this will parse the command line arguments passed when the Node.js process was launched, extracted from process.argv
.
The output object will have the following keys:
arguments
: anarray
with all the arguments that did not have an option associated with it.options
: anobject
with all the single and double hyphened arguments.
var getArgs = ; //Parse aconsole;// { arguments: [ 'run' ],// options: { file: '/path/to/file.txt', x: '5' } }
Run example
There is a script called example.js
to test how this module works.
$ node example.js foo bar -i 5 -jkw -y 10 --message "Hello world"
Limitations
get-args
can't parse arguments with the format--foo=bar
.
If you implement a solution that solves anyone of the limitations listed before, feel free to submit your PR.
License
MIT © Josemi Juanes.