Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ethanent/gar
Node arguments parser
https://github.com/ethanent/gar
args argument argument-parser argument-parsing arguments argv argv-parser javascript node node-js nodejs npm npm-package
Last synced: about 2 hours ago
JSON representation
Node arguments parser
- Host: GitHub
- URL: https://github.com/ethanent/gar
- Owner: ethanent
- License: mit
- Created: 2017-12-30T23:22:22.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-04T07:23:58.000Z (almost 6 years ago)
- Last Synced: 2024-03-19T20:23:17.719Z (8 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
![gar usage demo](https://i.imgur.com/Ln6A8Nn.png)
```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 | [![optimist package size](https://packagephobia.now.sh/badge?p=optimist)](https://packagephobia.now.sh/result?p=optimist)
minimist | [![minimist package size](https://packagephobia.now.sh/badge?p=minimist)](https://packagephobia.now.sh/result?p=minimist)
args-parser | [![args-parser package size](https://packagephobia.now.sh/badge?p=args-parser)](https://packagephobia.now.sh/result?p=args-parser)
gar | [![gar package size](https://packagephobia.now.sh/badge?p=gar)](https://packagephobia.now.sh/result?p=gar)