# argv-parse

> Parse command line arguments.

Latest version **1.0.1** (published 2016-03-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install argv-parse
pnpm add argv-parse
yarn add argv-parse
bun add argv-parse
```

## 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.0.1 |
| Published | 2016-03-07 |
| First published | 2016-02-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Paul C Pederson |
| Maintainers | paulcpederson |
| Keywords | args, argv, cli, parse |

## Links

- npm: https://www.npmjs.com/package/argv-parse
- Repository: https://github.com/paulcpederson/argv-parse
- Issues: https://github.com/paulcpederson/argv-parse/issues
- npm.io page: https://npm.io/package/argv-parse

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-03-07
- 1.0.0 — 2016-02-16

## README

# argv-parse

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]

[npm-image]: https://img.shields.io/npm/v/argv-parse.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/argv-parse
[travis-image]: https://img.shields.io/travis/paulcpederson/argv-parse.svg?style=flat-square
[travis-url]: https://travis-ci.org/paulcpederson/argv-parse
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard

Parse command line arguments. This is a lot like [yargs](https://www.npmjs.com/package/yargs) or [optimist](https://www.npmjs.com/package/optimist) but not as feature rich.

You can specify flags, aliases, or not. Can pass arrays, strings, and booleans. No dependencies.

If you don't need array arguments, I'd recommend using [minimist](https://www.npmjs.com/package/minimist) which is very good.

## Install

```
npm install argv-parse
```

## Usage

Say you had a file like `foo-bar-qux.js` which needed to parse arguments:

```js
var argv = require('argv-parse')

// accepts a definition object and args
// if args is undefined, defaults to process.argv.slice(2)
var args = argv({
  foo: {
    type: 'boolean',
    alias: 'f'
  },
  bar: {
    type: 'string',
    alias: 'b'
  },
  qux: {
    type: 'array',
    alias: 'q'
  },
  norf: {
    type: 'boolean',
    alias: 'n'
  }
})
console.dir(args)
```

```
$ node foo-bar-qux.js --foo
{
  foo: true
}

$ node foo-bar-qux.js --bar hey
{
  bar: 'hey'
}

$ node foo-bar-qux.js --qux thing1 thing2 thing3
{
  qux: ['thing1', 'thing2', 'thing3']
}

$ node foo-bar-qux.js -f -b hey -q thing1 thing2 thing3
{
  foo: true,
  bar: 'hey',
  qux: ['thing1', 'thing2', 'thing3']
}

$ node foo-bar-qux.js -fn
{
  foo: true,
  norf: true
}

$ node foo-bar-qux.js not specified
{
  _: ['not', 'specified']
}

$ node foo-bar-qux.js --unknown surprise
{
  unknown: 'surprise'
}
```

If you don't care about aliases or types, you don't actually need to configure anything, `argv-parse` will intelligently guess how the unknown flag should be interpreted:

*simple.js*

```
var argv = require('argv-parse')
var args = argv()
console.dir(args)
```

```
$ node simple.js --unknown
{
  unknown: true
}

$ node simple.js --unknown hey
{
  unknown: 'hey'
}

$ node simple.js --unknown hey you
{
  unknown: ['hey', 'you']
}

$ node simple.js first second --unknown hey you
{
  _: ['first', 'second'],
  unknown: ['hey', 'you']
}
```

## License

[ISC](LICENSE)

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