UNPKG

1.06 kBMarkdownView Raw
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
9npm i gar
10```
11
12## Use
13
14```javascript
15const opts = require('gar')(process.argv.slice(2))
16
17console.log(opts)
18```
19
20So 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
37gar 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
41Package | Size (KB) | Dependencies<br />(Tree Count) | Size Comparison<br />(vs. gar)
42--- | --- | --- | ---
43optimist | 109 | [2](http://npm.anvaka.com/#/view/2d/optimist) | 27.25x
44minimist | 31 | [0](http://npm.anvaka.com/#/view/2d/minimist) | 7.75x
45args-parser | 15 | [0](http://npm.anvaka.com/#/view/2d/args-parser) | 3.75x
46gar | 4 | [0](http://npm.anvaka.com/#/view/2d/gar) | 1x
\No newline at end of file