{"id":13757719,"url":"https://github.com/fluents/funwithflags","last_synced_at":"2025-05-10T05:32:15.667Z","repository":{"id":57243248,"uuid":"89653112","full_name":"fluents/funwithflags","owner":"fluents","description":"parse argument options","archived":false,"fork":false,"pushed_at":"2017-04-29T03:10:45.000Z","size":32,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-16T13:35:19.218Z","etag":null,"topics":["alias","args","arguments","argv","chainable","cli","flags","fluent","minimist","options","parser"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fluents.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-28T00:56:29.000Z","updated_at":"2017-06-14T11:57:03.000Z","dependencies_parsed_at":"2022-09-15T08:50:32.910Z","dependency_job_id":null,"html_url":"https://github.com/fluents/funwithflags","commit_stats":null,"previous_names":["aretecode/funwithflags"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluents%2Ffunwithflags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluents%2Ffunwithflags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluents%2Ffunwithflags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluents%2Ffunwithflags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluents","download_url":"https://codeload.github.com/fluents/funwithflags/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253371076,"owners_count":21897998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alias","args","arguments","argv","chainable","cli","flags","fluent","minimist","options","parser"],"created_at":"2024-08-03T12:00:46.673Z","updated_at":"2025-05-10T05:32:15.229Z","avatar_url":"https://github.com/fluents.png","language":"JavaScript","readme":"# 🚩 funwithflags\n\n![funwithflags]\n\n[![Build Status][travis-image]][travis-url]\n[![NPM version][funwithflags-npm-image]][funwithflags-npm-url]\n[![MIT License][license-image]][license-url]\n[![fliphub][gitter-badge]][gitter-url]\n[![fluents][fluents-image]][fluents-url]\n\n\u003e parse argument options\n\nThis module is [minimist](https://github.com/substack/minimist) refactored as a fluent class ~125% faster.\n\n[![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist)\n\n\n### [📘 examples](https://github.com/aretecode/funwithflags/wiki/examples)\n\n``` js\nvar argv = require('funwithflags')(process.argv.slice(2));\nconsole.log(argv);\n```\n\n### [📦 install][funwithflags-npm-url]\n\n```\nyarn add funwithflags --dev\nnpm install funwithflags --save-dev\n```\n\n### ⚙ options\n\n| Name | Type | Description | ?Default | Example  |\n| ---- | ---- | ----------- | -------- | -------- |\n| [string][examples-string] | \u003ccode\u003estring \u0026#124; Array\u0026lt;string\u0026gt;\u003c/code\u003e | names to always treat as strings | `null` |\n| [boolean][examples-boolean] | \u003ccode\u003eboolean \u0026#124; string \u0026#124; Array\u0026lt;string\u0026gt;\u003c/code\u003e | always treat as booleans. if `true` will treat all double hyphenated arguments without equal signs. (e.g. affects `--foo`, not `-f` or `--foo=bar`) | `null` |\n| [alias][examples-alias] | `Object` | an object mapping string names to strings or arrays of string names to use as aliases | `{}` |\n| [default][examples-default] | `Object` | an object mapping string argument names to default values| `{}` |\n| [`['--']`][examples-dd] | `boolean` | populate `argv._` with everything before the `--` and `argv['--']` with everything after the `--` | `null` |\n| [stopEarly][examples-stop-early] | `boolean` | when true, populate `argv._` with everything after the first non-option| `null` |\n| [unknown][examples-unknown] | `Function` | a function which is invoked with a command line parameter not defined in the `opts` configuration object. If the function returns `false`, the unknown option is not added to `argv` | `null` |\n| [obj][examples-obj] | `boolean` | when true, returns the object instance of FunWithFlags | `null` |\n| [vars][examples-vars] | `boolean` | when true, allows args without dashes to be used as flags | `null` |\n| camel | `boolean` | when true, camelCases object keys on argv | `null` |\n| underscore | `boolean` | when false, object is returned with no `_` (for looping over object keys or values or the like) | `null` |\n\n\n### [extending the class][examples-extending]\n\n[examples-vars]: https://github.com/aretecode/funwithflags/wiki/examples#vars\n[examples-obj]: https://github.com/aretecode/funwithflags/wiki/examples#obj\n[examples-alias]: https://github.com/aretecode/funwithflags/wiki/examples#alias\n[examples-default]: https://github.com/aretecode/funwithflags/wiki/examples#default\n[examples-unknown]: https://github.com/aretecode/funwithflags/wiki/examples#unknown\n[examples-string]: https://github.com/aretecode/funwithflags/wiki/examples#types\n[examples-boolean]: https://github.com/aretecode/funwithflags/wiki/examples#types\n[examples-dd]: https://github.com/aretecode/funwithflags/wiki/examples#double-dash\n[examples-stop-early]: https://github.com/aretecode/funwithflags/wiki/examples#stop-early\n[examples-extending]:  https://github.com/aretecode/funwithflags/wiki/examples#extending\n[examples-verbose]:  https://github.com/aretecode/funwithflags/wiki/examples-verbose\n\n# [🔬 tests](./test)\n- tests use [ava](https://github.com/avajs/ava)\n\n# [🏋️ benchmarks](./bench)\n\u003c!-- benchmark img --\u003e\n- benchmarks use [benchmark.js](benchmarkjs.com) with [bench-chain](https://github.com/aretecode/bench-chain)\n\n\n#### [verbose][examples-verbose]\n```js\n\nvar unknown = []\n\n// captures the unknown args, similar to how `vars` does\nfunction unknownFn(arg) {\n  unknown.push(arg)\n  return true\n}\n\nvar opts = {\n  'default': {\n    'moose.box': 11,\n    'eh': true,\n    'igloo': false,\n  },\n  'alias': {\n    'moose.box': 'mooses.boxes',\n    'rain': 'british-columbia',\n  },\n  'boolean': ['eh', 'igloo'],\n  'string': ['country', 'nan', 'noflag'],\n  'vars': true,\n  '--': true,\n  'obj': true, // will return the instance\n  'unknown': unknownFn,\n}\n\nvar args = [\n  '--country=canada',\n\n  // aliased to `rain` so it will have `rain: true, 'british-columbia': true`\n  '--british-columbia',\n\n  // no value is default a true boolean\n  '--igloo',\n\n  // dot notation\n  '--a.b=100',\n\n  // using `string: 'nan'` we ensure this stays as a string\n  '--nan',\n  '99',\n\n  // first flag is boolean (t: true)\n  // second flag assigned to following value (f: 555)\n  '-tf',\n  '555',\n\n  // mooses and globbing are parsed only because `vars: true``\n  'mooses.boxes=moozes',\n  'globbing',\n  `\"**/*\"`,\n\n  // after double dash\n  '--',\n  'dis-little-piggy',\n  'went-to-market',\n]\n\nvar obj = require('../')(args, opts)\nconst argv = obj.argv\n\n```\n\n\n\n[fluents-image]: https://img.shields.io/badge/⛓-fluent-9659F7.svg\n[fluents-url]: https://www.npmjs.com/package/flipchain\n\n\n[funwithflags1]: http://funwithflags.info/img/funwhitflagLogo.png\n[funwithflags]: https://68.media.tumblr.com/02297f01d9716cede3879e7e139e0cfc/tumblr_inline_o7p6oyQ6cT1r18apd_500.gif\n\n[funwithflags-npm-image]: https://img.shields.io/npm/v/funwithflags.svg\n[funwithflags-npm-url]: https://npmjs.org/package/funwithflags\n[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat\n[license-url]: https://spdx.org/licenses/MIT\n[gitter-badge]: https://img.shields.io/gitter/room/fliphub/pink.svg\n[gitter-url]: https://gitter.im/fliphub/Lobby\n[travis-url]: http://travis-ci.org/substack/minimist\n[travis-image]: https://travis-ci.org/substack/minimist.png\n","funding_links":[],"categories":["My Fluent Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluents%2Ffunwithflags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluents%2Ffunwithflags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluents%2Ffunwithflags/lists"}