# bargs

> ✨ A simple argument parsing system with 0 dependencies

Latest version **1.0.4** (published 2022-01-18) · GPL-3.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install bargs
pnpm add bargs
yarn add bargs
bun add bargs
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2022-01-18 |
| First published | 2020-11-17 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 58.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Barış DEMİRCİ |
| Maintainers | leydihavuc |
| Keywords | args, arg, argument, parser, parse, argv, parsing, argument-parser, arguments, argv-parser |

## Links

- npm: https://www.npmjs.com/package/bargs
- Repository: https://github.com/barbarbar338/bargs
- Homepage: https://github.com/barbarbar338/bargs#readme
- Issues: https://github.com/barbarbar338/bargs/issues
- npm.io page: https://npm.io/package/bargs

## 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.0.4 (latest) — 2022-01-18
- 1.0.3 — 2021-05-27
- 1.0.2 — 2021-02-12
- 1.0.1 — 2020-11-18
- 1.0.0 — 2020-11-17

## README

# 🦄 Bargs

-   A simple argument parsing system with 0 dependencies ✨

# 📥 Installation

Using yarn:

```
$ yarn add bargs
```

Using npm:

```
$ npm install bargs
```

# 🔧 Usage

```js
bargs(OptionDefinitions, argv?);
```

-   `OptionDefinitions`: Where options are defined to be used when separating arguments. Structure:

```js
[
    {
        name: "OptionName",
        type: String, //OptionType (function)
        aliases?: [ "option", "aliases", "t" ],
        default?: false
    }
]
```

-   `argv?`: Arguments to parse. Default is `process.argv.slice(2)`.

# 🛠️ Example

```js
/* es6 */
import { bargs } from "bargs";

/* commonJS */
const { bargs } = require("bargs");

const definitions = [
	{ name: "help", type: Boolean, aliases: ["h", "halp", "yardim", "y"] },
	{ name: "message", type: String, default: true },
	{ name: "page", type: Number },
];

const argv = ["This", "is", "message", "-h", "--page", "2", "--foo", "bar"];

bargs(definitions, argv);
/*
 * {
 *     _unknown: {
 *         foo: "bar"
 *     },
 *     help: true,
 *     message: "This is message",
 *     page: 2
 * }
 */
```

# 🔗 Contributing / Issues / Ideas

Feel free to use GitHub's features ✨

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