get-them-args

Parse argument options
Table of Contents
About
Simple CLI argument parser hacked from minimist that adds support for objects and additional initialization options.
Install
$ npm install --save get-them-args
$ yarn add get-them-args
Usage
To use, provide arguments as argument:
const parse = require('get-them-args')
const options = {}
console.log(parse(process.argv.slice(2) ))
console.log(parse(process.argv))
console.log(parse())
For example, if the arguments provided are --hello world --parse=all --no-drugs --make-friends -n 4 -t 5
, the function will return:
{ unknown: [],
hello: 'world',
parse: 'all',
drugs: false,
'make-friends': true,
n: 4,
t: 5
}
There is also support for parsing objects:
$ node example.js --headers={"Foo": "5", "bar": "6"}
All unparsed arguments will end up in the unknown
array. The following types of arguments are supported:
--key=value
--key value
--key
--no-key
-key=value
-key value
Contribute
- Fork it and create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request
License
MIT