{"_id":"argparse@3.0.2","bugs":{"url":"https://github.com/nodeca/argparse/issues"},"dist":{"shasum":"6d0ad05840b8aa929fb2cc22936926f3ef04fbe8","tarball":"http://registry-npm.ywwl.com/argparse/download/argparse-3.0.2.tgz","fileCount":9,"integrity":"sha512-mFdDM6WqWKraGLsVb+C9CahPnzTXOefAOLq3jYcca2YZ8bEWpr++Tzj+zSaKW9+X9L5uSxcm1AZ3Y6aZJ09OhQ==","signatures":[{"sig":"MEUCIQCUYo+0Ul51SO3wARImV93zeTtAfAOj419GmcDeabfYTQIgcdymji7DRO91ktDUNOCIMU+seWj4yuZxN6yepwd+Iy0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCIDuCNm3inz7j0sG/3nHZN0xkpkzVHKMtr9WtwBxmu6wIgZh1uLpUiMU/5lWgnYMQ+gJ27MpJyitHMgACanzX3Bu0="}],"unpackedSize":177250,"size":39597,"noattachment":false,"key":"/argparse/-/argparse-3.0.2.tgz"},"main":"lib/argparse.js","name":"argparse","types":"lib/argparse.d.ts","funding":[{"url":"https://github.com/sponsors/puzrin","type":"github"},{"url":"https://github.com/sponsors/nodeca","type":"github"}],"gitHead":"b24ea1892b4b7e7a268cd4554cdd654ec47c148f","license":"PSF-2.0","scripts":{"lint":"eslint .","test":"npm run lint && node --test","coverage":"c8 --reporter html npm test"},"version":"3.0.2","_npmUser":{"name":"vitaly","email":"vitaly@rcopen.com"},"homepage":"https://github.com/nodeca/argparse#readme","keywords":["cli","parser","argparse","option","args"],"repository":{"url":"git+https://github.com/nodeca/argparse.git","type":"git"},"_npmVersion":"11.13.0","description":"CLI arguments parser. Native port of python's argparse.","directories":{},"maintainers":[{"name":"vitaly","email":"vitaly@rcopen.com"}],"_nodeVersion":"24.16.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^11.0.0","neostandard":"^0.13.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/argparse_3.0.2_1789065842038_0.26453332026040277"},"readme":"argparse\n========\n\n[![CI](https://github.com/nodeca/argparse/actions/workflows/ci.yml/badge.svg)](https://github.com/nodeca/argparse/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse)\n\nCLI arguments parser for node.js, with [sub-commands](https://docs.python.org/3.14/library/argparse.html#sub-commands) support. Port of python's [argparse](https://docs.python.org/3.14/library/argparse.html) (version [3.14.6](https://github.com/python/cpython/blob/v3.14.6/Lib/argparse.py)).\n\n**Difference with original.**\n\n- JS has no keyword arguments support.\n  -  Pass options instead: `new ArgumentParser({ description: 'example', add_help: true })`.\n- JS has no python's types `int`, `float`, ...\n  - Use string-typed names: `.add_argument('-b', { type: 'int', help: 'help' })`.\n- `%r` format specifier uses `require('util').inspect()`.\n\nSee the complete list of [differences from Python](./doc/port_difference.md).\nUsers upgrading from v2 should read the [migration guide](./doc/migrate_v2_to_v3.md).\n\n\nExample\n-------\n\nFollowing code is a JS program that takes a list of integers and produces either the sum or the max:\n\n```js\nconst { ArgumentParser } = require('argparse')\n\nconst parser = new ArgumentParser({ description: 'Process some integers.' })\n\nlet sum = ints => ints.reduce((a, b) => a + b)\nlet max = ints => ints.reduce((a, b) => a > b ? a : b)\n\nparser.add_argument('integers', { metavar: 'N', type: 'int', nargs: '+',\n                                  help: 'an integer for the accumulator' })\nparser.add_argument('--sum',    { dest: 'accumulate', action: 'store_const',\n                                  const: sum, default: max,\n                                  help: 'sum the integers (default: find the max)' });\n\nlet args = parser.parse_args()\nconsole.log(args.accumulate(args.integers))\n```\n\nAssuming the JS code above is saved into a file called prog.js, it can be run at the command line and provides useful help messages:\n\n```\n$ node prog.js -h\nusage: prog.js [-h] [--sum] N [N ...]\n\nProcess some integers.\n\npositional arguments:\n  N           an integer for the accumulator\n\noptions:\n  -h, --help  show this help message and exit\n  --sum       sum the integers (default: find the max)\n```\n\nWhen run with the appropriate arguments, it prints either the sum or the max of the command-line integers:\n\n```\n$ node prog.js 1 2 3 4\n4\n$ node prog.js 1 2 3 4 --sum\n10\n```\n\nIf invalid arguments are passed in, it will issue an error:\n\n```\n$ node prog.js a b c\nusage: prog.js [-h] [--sum] N [N ...]\nprog.js: error: argument N: invalid 'int' value: 'a'\n```\n\nThis is an example ported from Python. You can find detailed explanation [here](https://docs.python.org/3.14/library/argparse.html).\n\n\nAPI docs\n--------\n\nSince this is a port with minimal divergence, there's no separate documentation.\nUse original one instead, with notes about difference.\n\n1. [Original doc](https://docs.python.org/3.14/library/argparse.html).\n2. [Original tutorial](https://docs.python.org/3.14/howto/argparse.html).\n3. [Differences from Python](./doc/port_difference.md).\n4. [Migration from v2 to v3](./doc/migrate_v2_to_v3.md).\n","publish_time":1789065842120,"_cnpm_publish_time":1789065842120,"dist-tags":{"latest":"3.0.4"}}