# args-parser

> Straight-forward node.js arguments parser

Latest version **1.3.0** (published 2021-07-08) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install args-parser
pnpm add args-parser
yarn add args-parser
bun add args-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2021-07-08 |
| First published | 2016-02-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | eveningkid |
| Maintainers | eveningkid |
| Keywords | args, parser, args-parser, arguments |

## Links

- npm: https://www.npmjs.com/package/args-parser
- Repository: https://github.com/eveningkid/args-parser
- Homepage: https://github.com/eveningkid/args-parser#readme
- Issues: https://github.com/eveningkid/args-parser/issues
- npm.io page: https://npm.io/package/args-parser

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.3.0 (latest) — 2021-07-08
- 1.2.0 — 2021-05-07
- 1.1.0 — 2017-03-19
- 1.0.2 — 2016-02-07
- 1.0.1 — 2016-02-07
- 1.0.0 — 2016-02-06

## README

# args-parser

Straight-forward node.js arguments parser.

```bash
$ node ./script.js careful -dangerous --tomatoes=3 --tonight --key=ek==

{
  "careful": true,
  "dangerous": true,
  "tomatoes": 3,
  "tonight": true,
  "key": "ek=="
}
```

## How to use it?

```bash
$ npm install args-parser
```

Simply call the module passing it an `arguments` array such as `process.argv`:

```javascript
const args = require('args-parser')(process.argv);
console.info(args);
```

The returned value is an `Object` having a key for each given argument and a value if it's found an `=` sign (`true` otherwise).

Consider this command:

```bash
$ node ./script.js careful -dangerous --tomatoes=3 --tonight --key=ek==
```

Will return:

```json
{
  "careful": true,
  "dangerous": true,
  "tomatoes": 3,
  "tonight": true,
  "key": "ek=="
}
```

So then you can easily check what you need:

```javascript
if (args.careful) {
  // Do something
}
```

---
_Source: https://npm.io/package/args-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
