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 | ![gar usage demo](https://i.imgur.com/Ln6A8Nn.png)
|
15 |
|
16 | ```javascript
|
17 | const args = require('gar')(process.argv.slice(2))
|
18 |
|
19 | console.log(args)
|
20 | ```
|
21 |
|
22 | So 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 |
|
39 | gar is way more lightweight than other argument parsing packages.
|
40 |
|
41 | Here's a size comparison table:
|
42 |
|
43 | Package | Size
|
44 | --- | ---
|
45 | optimist | [![optimist package size](https://packagephobia.now.sh/badge?p=optimist)](https://packagephobia.now.sh/result?p=optimist)
|
46 | minimist | [![minimist package size](https://packagephobia.now.sh/badge?p=minimist)](https://packagephobia.now.sh/result?p=minimist)
|
47 | args-parser | [![args-parser package size](https://packagephobia.now.sh/badge?p=args-parser)](https://packagephobia.now.sh/result?p=args-parser)
|
48 | gar | [![gar package size](https://packagephobia.now.sh/badge?p=gar)](https://packagephobia.now.sh/result?p=gar) |
\ | No newline at end of file |