# opted

> Stringify an object to command line options

Latest version **1.0.2** (published 2017-03-11) · MIT license · 0 weekly downloads

## Install

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

## 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.2 |
| Published | 2017-03-11 |
| First published | 2015-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andrew Nichols |
| Maintainers | tandrewnichols |
| Keywords | options, params, flags, arguments, args, parameters, cli, command, line |

## Links

- npm: https://www.npmjs.com/package/opted
- Repository: https://github.com/tandrewnichols/opted
- Issues: https://github.com/tandrewnichols/opted/issues
- npm.io page: https://npm.io/package/opted

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## 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.2 (latest) — 2017-03-11
- 1.0.1 — 2017-03-11
- 1.0.0 — 2015-07-21

## README

[![Build Status](https://travis-ci.org/tandrewnichols/opted.png)](https://travis-ci.org/tandrewnichols/opted) [![downloads](http://img.shields.io/npm/dm/opted.svg)](https://npmjs.org/package/opted) [![npm](http://img.shields.io/npm/v/opted.svg)](https://npmjs.org/package/opted) [![Code Climate](https://codeclimate.com/github/tandrewnichols/opted/badges/gpa.svg)](https://codeclimate.com/github/tandrewnichols/opted) [![Test Coverage](https://codeclimate.com/github/tandrewnichols/opted/badges/coverage.svg)](https://codeclimate.com/github/tandrewnichols/opted) [![dependencies](https://david-dm.org/tandrewnichols/opted.png)](https://david-dm.org/tandrewnichols/opted)

# opted

Stringify an object to command line options

## Installation

`npm install --save opted`

## Usage

Opted is _not_ a command line option parser. Rather, it is a library for stringifying an object into a list of command line arguments. E.g.

```js
var opted = require('opted');
var args = opted({ foo: 'bar' });
console.log(args); // ['--foo', 'bar']
```

## Types of flags

### Long

Options are [kebab-cased](https://lodash.com/docs#kebabCase) and prefixed with '--'.

```js
console.log( opted({ foo: 'bar' }) ); // ['--foo', 'bar']
console.log( opted({ fooBar: 'baz' }) ); // ['--foo-bar', 'baz']
```

### Short

Options that have single letter abbreviations can also be used.

```js
console.log( opted({ f: 'bar' }) ); // ['-f', 'bar']
```

### Boolean

Options that are simple "on", but have no value, can be set to `true`. Setting a flag to false, will add 'no' to the beginning.

```js
console.log( opted({ bananas: true }) ); // ['--bananas']
console.log( opted({ bananas: false }) ); // ['--no-bananas']
```

### Equal style

Options that include an equal sign will keep the equal sign.

```js
console.log( opted({ 'name=', 'Andrew' }) ); // ['--name=Andrew']
```

### List

Multiple options for a single flag can be passed in an array.

```js
console.log( opted({ member: ['Bob', 'Larry'] }) ); // ['--member', 'Bob', '--member', 'Larry']
```

## But wait, the tool I need to pass args to is some bizarre abomination like "find" that uses single dashes...

No problem. Just enable crazy-arg mode by passing true as the second parameter.

```js
console.log( opted({ hello: 'world' }, true) ); // ['-hello', 'world']
```

## Contributing

Please see [the contribution guidelines](CONTRIBUTING.md).

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