# argv-formatter

> Bizarro minimist: transform an options object into argv

Latest version **1.0.0** (published 2014-11-23) · MIT license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2014-11-23 |
| First published | 2014-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | argv, formatting, child_process |

## Links

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

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-11-23

## README

argv-formatter
==============

Bizarro [minimist](https://github.com/substack/minimist): transform an options object into into a `process.argv`-like array. Helpful for using `child_process` and passing complex arguments more easily. 

## Setup

```bash
$ npm install --save argv-formatter
```

## API

#### `formatter.format(object)` -> `Array`

Accepts an `object` of containing options and arguments and returns an array of arguments. 

* options with a value of `true` will be included with a flag only (`{R: true}` -> `['-R']`)
* options that are falsey will be removed
* all values will be stringified, (`{D: new Date(0)}` -> `['-D', 'Thurs Jan 1 1970...']`)
* arguments can be passed under the `_` key as a value or array of values

## Examples

To generate arguments to a `git log` command for printing the short hashes of commits that have changed our test files:
```js
var args = formatter.format({
  _: './test/*',
  format: '%h'
});
console.log(args.join(' ')); // --format=%h ./test/*

```

[git-log-parser](https://github.com/bendrucker/git-log-parser) uses this to spawn a `git` process:

```js
var spawn     = require('child_process').spawn;
var formatter = require('argv-formatter');
var args      = formatter.format(options);
var child     = spawn('git', ['log'].concat(args));
```

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