{"_id":"to-flag","_rev":"45753","name":"to-flag","description":"Create a command-line argument from a string or string (key) and value.","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T10:14:05.000Z","created":"2015-08-07T21:22:15.359Z","1.0.0":"2015-08-07T21:22:15.359Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/to-flag.git"},"versions":{"1.0.0":{"name":"to-flag","description":"Create a command-line argument from a string or string (key) and value.","version":"1.0.0","homepage":"https://github.com/jonschlinkert/to-flag","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/to-flag.git"},"bugs":{"url":"https://github.com/jonschlinkert/to-flag/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"collapse-object":"^0.1.0","dashify":"^0.1.0","is-primitive":"^2.0.0"},"devDependencies":{"mocha":"*","should":"*"},"keywords":["arg","args","arguments","argv","bin","cli","cmd","command","command-line","expand","flag","flags","line","minimist","nopt","opt","options","opts"],"verb":{"related":{"list":["to-flags","minimist-plugins","minimist-events","minimist-methods","minimist-expand"]}},"gitHead":"5b0a30e0651796cc4142c8997fd3a4d9b889af70","_id":"to-flag@1.0.0","_shasum":"fffeb5ef3357f3c5e64cfd21e7e1698d044c834b","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"fffeb5ef3357f3c5e64cfd21e7e1698d044c834b","size":2645,"noattachment":false,"key":"/to-flag/-/to-flag-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/to-flag/download/to-flag-1.0.0.tgz"},"directories":{},"publish_time":1438982535359,"_cnpm_publish_time":1438982535359,"_hasShrinkwrap":false}},"readme":"# to-flag [![NPM version](https://badge.fury.io/js/to-flag.svg)](http://badge.fury.io/js/to-flag)  [![Build Status](https://travis-ci.org/jonschlinkert/to-flag.svg)](https://travis-ci.org/jonschlinkert/to-flag)\n\n> Create a command-line argument from a string or string (key) and value.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm i to-flag --save\n```\n\n## Usage\n\n```js\nvar toFlag = require('to-flag');\n\ntoFlag('abc');\n//=> '--abc'\n\ntoFlag('abc', true);\n//=> '--abc'\n\ntoFlag('abc', 'xyz');\n//=> '--abc=xyz'\n\ntoFlag('abc', 'true');\n//=> '--abc=true'\n\ntoFlag('abc', 10);\n//=> '--abc=10'\n```\n\n**casing**\n\nKeys that are camelcase or contain spaces will be dash-cased:\n\n```js\ntoFlag('fooBar');\n//=> '--foo-bar'\n\ntoFlag('a b c');\n//=> '--a-b-c'\n\ntoFlag('A');\n//=> '--a'\n```\n\n## Usage example\n\n```js\nvar obj = {\n  foo: 'bar',\n  abc: true,\n  xyz: 10,\n  one: false\n};\n\nvar args = Object.keys(obj).map(function (key) {\n  return toFlag(key, obj[key]);\n});\n//=> ['--foo=bar', '--abc', '--xyz=10', '--no-one']\n```\n\n## Options\n\n### invert\n\nWhen the value is `false` an inverted flag is created by default:\n\n```js\ntoFlag('a', false);\n//=> '--no-a'\n```\n\nTo disable inversion, pass `false` on the options:\n\n```js\ntoFlag('a', false, {invert: false});\n//=> '--a'\n```\n\n## Related\n\n* [minimist-plugins](https://github.com/jonschlinkert/minimist-plugins): Simple wrapper to make minimist pluggable. ~20 sloc.\n* [minimist-events](https://github.com/jonschlinkert/minimist-events): Add events to minimist, ~30 sloc.\n* [minimist-methods](https://github.com/jonschlinkert/minimist-methods): Map your node.js application's methods to command line arguments.\n* [minimist-expand](https://github.com/jonschlinkert/minimist-expand): Expand minimist args with expand-object.\n* [to-flags](https://github.com/jonschlinkert/to-flags): Convert the properties of an object to command line flags.\n\n## Run tests\n\nInstall dev dependencies:\n\n```sh\n$ npm i -d && npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/to-flag/issues/new)\n\n## Author\n\n**Jon Schlinkert**\n\n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\nThis was originally inspired by [grunt.option](https://github.com/gruntjs/grunt/blob/master/lib/grunt/option.js#L40).\n\n## License\n\nCopyright © 2015 Jon Schlinkert\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 07, 2015._","_attachments":{},"homepage":"https://github.com/jonschlinkert/to-flag","bugs":{"url":"https://github.com/jonschlinkert/to-flag/issues"},"license":"MIT"}