https://github.com/ethan7g/gar
Node arguments parser
https://github.com/ethan7g/gar
args argument argument-parser argument-parsing arguments argv argv-parser javascript node node-js nodejs npm npm-package
Last synced: 7 months ago
JSON representation
Node arguments parser
- Host: GitHub
- URL: https://github.com/ethan7g/gar
- Owner: ethan7g
- License: mit
- Created: 2017-12-30T23:22:22.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-04T07:23:58.000Z (about 7 years ago)
- Last Synced: 2025-03-24T07:56:59.256Z (11 months ago)
- Topics: args, argument, argument-parser, argument-parsing, arguments, argv, argv-parser, javascript, node, node-js, nodejs, npm, npm-package
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 33
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gar
> The lightweight Node arguments parser
[GitHub](https://github.com/ethanent/gar) | [NPM](https://www.npmjs.com/package/gar)
## Install
```bash
npm i gar
```
## Use

```javascript
const args = require('gar')(process.argv.slice(2))
console.log(args)
```
So for: `-h hey --toggle -ac --hey=hi -spaced "hey there" -num 1 lone`
```json
{
"h": "hey",
"toggle": true,
"a": true,
"c": true,
"hey": "hi",
"spaced": "hey there",
"num": 1,
"_": ["lone"]
}
```
## Why use gar?
gar is way more lightweight than other argument parsing packages.
Here's a size comparison table:
Package | Size
--- | ---
optimist | [](https://packagephobia.now.sh/result?p=optimist)
minimist | [](https://packagephobia.now.sh/result?p=minimist)
args-parser | [](https://packagephobia.now.sh/result?p=args-parser)
gar | [](https://packagephobia.now.sh/result?p=gar)