UNPKG

1.24 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![gar usage demo](https://i.imgur.com/Ln6A8Nn.png)
15
16```javascript
17const args = require('gar')(process.argv.slice(2))
18
19console.log(args)
20```
21
22So for: `-h hey --toggle -ac --hey=hi -spaced "hey there" -num 1 lone`
23
24```json
25{
26 "h": "hey",
27 "toggle": true,
28 "a": true,
29 "c": true,
30 "hey": "hi",
31 "spaced": "hey there",
32 "num": 1,
33 "_": ["lone"]
34}
35```
36
37## Why use gar?
38
39gar is way more lightweight than other argument parsing packages.
40
41Here's a size comparison table:
42
43Package | Size
44--- | ---
45optimist | [![optimist package size](https://packagephobia.now.sh/badge?p=optimist)](https://packagephobia.now.sh/result?p=optimist)
46minimist | [![minimist package size](https://packagephobia.now.sh/badge?p=minimist)](https://packagephobia.now.sh/result?p=minimist)
47args-parser | [![args-parser package size](https://packagephobia.now.sh/badge?p=args-parser)](https://packagephobia.now.sh/result?p=args-parser)
48gar | [![gar package size](https://packagephobia.now.sh/badge?p=gar)](https://packagephobia.now.sh/result?p=gar)
\No newline at end of file