Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonschlinkert/to-flags

Convert the properties of an object to command line flags.
https://github.com/jonschlinkert/to-flags

Last synced: about 2 months ago
JSON representation

Convert the properties of an object to command line flags.

Awesome Lists containing this project

README

        

# to-flags [![NPM version](https://badge.fury.io/js/to-flags.svg)](http://badge.fury.io/js/to-flags)

> Convert the properties of an object to command line flags.

## Install

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i to-flags --save
```

## Usage

```js
var toFlags = require('to-flags');
```

## API

**Params**

* `obj` **{Object}**
* `keys` **{Array}**
* `returns` **{Array}**: Array of args

**Example**

```js
var options = {
foo: 'bar',
abc: true,
xyz: 10,
one: false
};

// create command line args for all options
toFlags(options);
//=> ['--foo=bar', '--abc', '--xyz=10', '--no-one']

// or specific options
toFlags(options, ['foo', 'abc']);
//=> ['--foo=bar', '--abc']
```

## Related projects

* [minimist-plugins](https://github.com/jonschlinkert/minimist-plugins): Simple wrapper to make minimist pluggable. ~20 sloc.
* [minimist-events](https://github.com/jonschlinkert/minimist-events): Add events to minimist, ~30 sloc.
* [minimist-methods](https://github.com/jonschlinkert/minimist-methods): Map your node.js application's methods to command line arguments.
* [minimist-expand](https://github.com/jonschlinkert/minimist-expand): Expand minimist args with expand-object.
* [to-flag](https://github.com/jonschlinkert/to-flag): Create a command-line argument from a string or string (key) and value.

## Running tests

Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/to-flags/issues/new)

## Author

**Jon Schlinkert**

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2015 Jon Schlinkert
Released under the MIT license.

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 07, 2015._