{"id":24592021,"url":"https://github.com/mrozio13pl/ofi","last_synced_at":"2026-02-10T19:34:54.494Z","repository":{"id":200036447,"uuid":"704594199","full_name":"mrozio13pl/ofi","owner":"mrozio13pl","description":"Yet another arguments parser.","archived":false,"fork":false,"pushed_at":"2025-01-29T14:49:19.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-06T07:08:16.716Z","etag":null,"topics":["args","argv","cli","cmd","command","commander","opt","options","parser","sade","yargs"],"latest_commit_sha":null,"homepage":"https://npm.im/ofi","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrozio13pl.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-13T15:40:32.000Z","updated_at":"2025-01-29T14:49:23.000Z","dependencies_parsed_at":"2024-04-01T17:31:25.163Z","dependency_job_id":"d11164cd-045b-40b2-813d-e81523efa356","html_url":"https://github.com/mrozio13pl/ofi","commit_stats":null,"previous_names":["mrozio13pl/ofi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrozio13pl%2Fofi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrozio13pl%2Fofi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrozio13pl%2Fofi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrozio13pl%2Fofi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrozio13pl","download_url":"https://codeload.github.com/mrozio13pl/ofi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244147218,"owners_count":20405940,"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":["args","argv","cli","cmd","command","commander","opt","options","parser","sade","yargs"],"created_at":"2025-01-24T10:13:27.579Z","updated_at":"2026-02-10T19:34:49.470Z","avatar_url":"https://github.com/mrozio13pl.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ofi\n\n[![npm][npm-version]][npm-link]\n[![npm bundle size][bundle-size]][bundlephobia]\n[![License][license]](./license)\n\n\u003e Yet another argument parser.\n\nA tiny cli flags parser.\n\n## Install\n\n```bash\nnpm i ofi\n```\n\n## Usage\n\nImport:\n\n```js\n// ESM\nimport { parse } from 'ofi';\n\n// or\nimport ofi from 'ofi';\n\n// CJS\nconst { parse } = require('ofi');\n```\n\nSetup options parser:\n\n```ts\nimport { parse } from 'ofi';\n\nparse(process.argv.slice(2), {\n     number: ['size'],\n     string: ['foo', 'name', 'surname'],\n     boolean: ['dice', 'friendly'],\n     array: ['list', 'my-numbers'],\n     alias: { foo: ['f'] },\n     default: { surname: 'obama', list: [] }\n});\n```\n\nThis would give the following results:\n\n```console\n$ node program.js --size=3 --name barack -f baz --no-dice --friendly\n{\n  _: [],\n  size: 3,\n  name: 'barack',\n  surname: 'obama',\n  foo: 'baz',\n  dice: false,\n  list: [],\n  friendly: true\n}\n\n$ node program.js --list a b c -N hi there --myNumbers=13,1,2,3 -fas\n{\n    _: ['hi', 'there'],\n    surname: 'obama',\n    list: [ 'a', 'b', 'c' ],\n    N: true,\n    'my-numbers': [ 13, 1, 2, 3 ],\n    foo: true,\n    a: true,\n    s: true\n}\n```\n\n## API\n\n### `parse(arguments, options?)`\nFunction that parses given arguments.\\\nReturns an argument object `argv` which contains all parsed flags.\n\n`argv._` includes all arguments that weren't associated with any option.\\\nAny argument after `--` ([end-of-flags](https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean)) won't be parsed and will end up in `argv._` and `argv['--']` if [`populate--`](#populate--) option is set to `true`.\n\n#### `arguments`\nType: `String | Array\u003cString\u003e`\\\nString or an array of strings to be parsed.\n\nFor example:\n```ts\nimport { parse } from 'ofi';\n\nparse(process.argv.slice(2));\n```\n\n#### `options`\n\nType: `Object`\\\nOptions for parsing given arguments.\n\n##### `boolean`\nArguments that should be parsed as booleans.\\\nType: `String | Array\u003cString\u003e`\n\n```js\n{ boolean: ['dice'] }\n```\nBooleans prefixed with `--no` will be treated as negations.\\\n\n##### `string`\nArguments that should be parsed as strings.\\\nType: `String | Array\u003cString\u003e`\n\n```js\n{ string: ['name'] }\n```\n\n##### `number`\nArguments that should be parsed as numbers.\\\nType: `String | Array\u003cString\u003e`\n\n```js\n{ number: ['age'] }\n```\n\n##### `array`\nArguments that should be parsed as arrays.\\\nType: `String | Array\u003cString\u003e`\n\n```js\n{ array: ['list'] }\n```\n\n##### `default`\nSet default values.\\\nType: `Object`\n\n```js\n{ default: { name: 'joe' } }\n```\n\n##### `alias`\nSet aliases of options.\\\nType: `Object`\n\n```js\n{ alias: { foo: ['f'], baz: 'b' } }\n```\n\n##### `populate--`\n\nPopulate `'--'` property in `Argv` with everything after double-dash (`--`, aka. end-of-flags).\n\nType: `Boolean`\\\nDefault: `false`\n\n##### `parseNumber`\nShould values that look like numbers be parsed into them.\n\nType: `Boolean`\\\nDefault: `true`\n\n**NOTE**: This doesn't apply to flags marked as strings.\n\n##### `shortFlagGroup`\nShould a group of short options be treated as seperate flags.\\\nExample: `-abc` -\u003e `{ a: true, b: true, c: true }`\n\nType: `Boolean`\\\nDefault: `true`\n\n##### `camelize`\nConvert results to camel-case.\n\nType: `Boolean`\\\nDefault: `false`\n\n##### `coerce`\nCustom synchronous function for parsing provided argument.\n\nType: `Object`\\\nDefault: `undefined`\n\n```js\n{ coerce: { len: (arg) =\u003e arg + ' cm' } }\n```\n\n##### `unknown`\n\nCallback function that runs whenever a parsed flag has not been defined in options.\n\nType: `Function`\\\nDefault: `undefined`\n\n```js\n{ unknown: function (flag) { console.log('Unknown flag: \"%s\"', flag); } }\n```\n\n## License\n\nMIT 💖\n\n\u003c!-- badges --\u003e\n[npm-link]: https://npmjs.com/package/ofi\n[npm-version]: https://img.shields.io/npm/v/ofi?labelColor=000\u0026color=57B759\n[bundle-size]: https://img.shields.io/bundlephobia/min/ofi?labelColor=000\u0026color=57B759\n[bundlephobia]: https://bundlephobia.com/package/ofi\n[license]: https://img.shields.io/npm/l/ofi?labelColor=000\u0026color=57B759","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrozio13pl%2Fofi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrozio13pl%2Fofi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrozio13pl%2Fofi/lists"}