1 | # gar
|
2 | > The lightweight Node arguments parser
|
3 |
|
4 | [GitHub](https://github.com/ethanent/gar) | [NPM](https://www.npmjs.com/package/gar)
|
5 |
|
6 | ## Install
|
7 |
|
8 | ```bash
|
9 | npm i gar
|
10 | ```
|
11 |
|
12 | ## Use
|
13 |
|
14 | ```javascript
|
15 | const opts = require('gar')(process.argv.slice(2))
|
16 |
|
17 | console.log(opts)
|
18 | ```
|
19 |
|
20 | So for: `-h hey --toggle -ac --hey=hi -spaced "hey there" -num 1 lone`
|
21 |
|
22 | ```json
|
23 | {
|
24 | "h": "hey",
|
25 | "toggle": true,
|
26 | "a": true,
|
27 | "c": true,
|
28 | "hey": "hi",
|
29 | "spaced": "hey there",
|
30 | "num": 1,
|
31 | "_": ["lone"]
|
32 | }
|
33 | ```
|
34 |
|
35 | ## Why use gar?
|
36 |
|
37 | gar is way more lightweight than other argument parsing packages.
|
38 |
|
39 | <img src="https://pbs.twimg.com/media/DSVYanWVwAADiCB.jpg:large" alt="gar is less than 4% the size of the optimist library."/>
|
40 |
|
41 | Package | Size (KB) | Dependencies<br />(Tree Count) | Size Comparison<br />(vs. gar)
|
42 | --- | --- | --- | ---
|
43 | optimist | 109 | [2](http://npm.anvaka.com/#/view/2d/optimist) | 27.25x
|
44 | minimist | 31 | [0](http://npm.anvaka.com/#/view/2d/minimist) | 7.75x
|
45 | args-parser | 15 | [0](http://npm.anvaka.com/#/view/2d/args-parser) | 3.75x
|
46 | gar | 4 | [0](http://npm.anvaka.com/#/view/2d/gar) | 1x |
\ | No newline at end of file |