{"library":"parameter-reducers","title":"CLI Parameter Reducers","description":"parameter-reducers is a JavaScript/TypeScript library designed for building robust and type-safe command-line interface (CLI) parameter parsers. Its current stable version is 2.1.0, and it appears to follow an active development cadence with recent feature additions and a significant breaking change in version 2.0.0. A key differentiator is its immutable, reducer-based chain API, which allows for flexible composition and reuse of parameter definitions. This approach facilitates highly customizable parsing logic while leveraging TypeScript to provide strong type guarantees for parsed arguments, reducing runtime errors associated with CLI argument processing. It focuses on core parsing capabilities, intentionally leaving documentation generation to user-defined template literals.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install parameter-reducers"],"cli":null},"imports":["import { startChain } from 'parameter-reducers';","import { param } from 'parameter-reducers';","import { parse } from 'parameter-reducers';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import {startChain, param, parse} from 'parameter-reducers';\n\nconst params = startChain()\n  .addParam(param.flag(['-h', '--help'], 'help'))\n  .addParam(param.string(['-m', '--message'], 'message'))\n  .addParam(param.integer(['-c', '--count'], 'count'));\n\nconst {help = false, message = 'hello world', count = 1} = parse(\n  params,\n  process.argv.slice(2),\n).extract();\n\nif (help) {\n  console.log(`Usage: repeat -m \"My Message\" -c 10\\n\\nparameters:\\n\\n-h --help    Print this help\\n-m --message The message to print\\n-c --count   How many times to print the message`);\n}\n\nfor (let i = 0; i < count; i++) {\n  console.log(message);\n}\n\n// Example execution: node your-script.ts -m \"Hello CLI\" -c 3","lang":"typescript","description":"Demonstrates basic CLI argument parsing for help flags, strings, and integers, including default values and help text output for a simple 'repeat' command.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}