# arrrg

> a simple CLI arrrgument parser.

Latest version **0.0.3** (published 2022-04-28) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2022-04-28 |
| First published | 2022-04-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | basedwon |

## Links

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

## Recent versions

- 0.0.3 (latest) — 2022-04-28
- 0.0.2 — 2022-04-16
- 0.0.1 — 2022-04-13
- 0.0.0 — 2022-04-13

## README

# Arrrg

`arrrg` is a simple CLI argument parser.

## Installation

```sh
npm install arrrg
```

## Usage

`arrrg(definition, [defaults], [examples], [argv])`

## Example

```js
const Arrrg = require('arrrg')

const definition = [
  { name: 'servn', type: String, command: true, default: '.', swap: 'docroot' },
  { name: 'host', type: String, help: 'define the host', default: 'localhost' },
  { name: 'file', type: String, aliases: ['f'], help: 'define the file', default: 'main.js' },
  { name: 'port', type: Number, aliases: ['p'], help: 'define the port', default: 8080 },
  { name: 'cert', help: 'define the TLS cert' },
  { name: 'help', type: Boolean, aliases: ['h', 'help'], help: 'show this dialog' },
]
const defaults = {
  host: 'localhost',
  file: 'main.js'
}
const examples = [
  `servn`,
  `servn -p 3000`,
  `servn ~/project --host example.com --file index.js`,
]
const argv = ['.', '--cert', 'localhost-key.pem', '--help']
const opts = Arrrg(definition, defaults, examples, argv)

console.log(opts)
/*
{
  _: [],
  servn: '.',
  cert: 'localhost-key.pem',
  help: true,
  host: 'localhost',
  file: 'main.js',
  port: 8080
}
*/

if (opts.help)
  return opts.showHelp() // showHelp result:
/*
  Servn

  Usage: servn ...args [options]

  Options:
    --host      define the host
    -f, --file  define the file
    -p, --port  define the port
    --cert      define the TLS cert
    -h, --help  show this dialog

  Examples:
    servn
    servn -p 3000
    servn ~/project --host example.com --file index.js
*/
```

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