{"name":"clap","version":"3.1.0","description":"Command line argument parser","author":{"name":"Roman Dvornov","email":"rdvornov@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/lahmatiy/clap.git"},"license":"MIT","keywords":["cli","command","option","argument","completion"],"type":"module","main":"lib/index.js","exports":{".":{"import":"./lib/index.js","require":"./cjs/index.cjs"},"./package.json":"./package.json"},"engines":{"node":"^12.20.0 || ^14.13.0 || >=15.0.0","npm":">=7.0.0"},"dependencies":{"ansi-colors":"^4.1.1"},"devDependencies":{"c8":"^7.11.0","eslint":"^8.8.0","mocha":"^9.2.0","rollup":"^2.67.1","test-console":"^2.0.0"},"scripts":{"lint":"eslint lib test","lint-and-test":"npm run lint && npm test","test":"mocha --reporter ${REPORTER:-progress}","test:cjs":"mocha cjs-test --reporter ${REPORTER:-progress}","watch":"npm run build -- --watch","build":"npm run esm-to-cjs --","build-and-test":"npm run esm-to-cjs-and-test","esm-to-cjs":"node scripts/esm-to-cjs","esm-to-cjs-and-test":"npm run esm-to-cjs && npm run test:cjs","coverage":"c8 --reporter=lcovonly npm test","prepublishOnly":"npm run lint-and-test && npm run build-and-test"},"gitHead":"4420f254faf5e546576085721ec8d50773ddd5f7","bugs":{"url":"https://github.com/lahmatiy/clap/issues"},"homepage":"https://github.com/lahmatiy/clap#readme","_id":"clap@3.1.0","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-4s3hnk5AsWxNZ0ndl6ngYg5Qtk4ghJHy3dAkdBUKcZZWBiSPU/Je8Cp74XFt9WmBipzgndcYkv20RWvZjrnYDw==","shasum":"7be57af5af236da61ab8cf9e5310d2af3457f297","tarball":"http://registry-npm.ywwl.com/clap/download/clap-3.1.0.tgz","fileCount":17,"unpackedSize":47262,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiATmbCRA9TVsSAnZWagAAGogP/A9bxh3PrVU5gU0LjoQh\nIVcr2lEgLQiBitW1lKfameQoyNcF/rnNm6OZsIv28VYa10aUha33nTaPZaTt\ndGAVnann6H+ZpXTzsftO3umKrIvUwDYE21DQRX+9FZl6BmTvbACmjF2Aa0mw\nitN+JB+1LBlcFRP3XUHVHLvLf6NVLhlEBFO4+8o9jFi+P/qypl6lwOTDVuEh\nonGbK2q2/bBEiN0Oay5HWf+WhXXoV9LQEcmOOgC2rCMsEMPR+PXbGapBainG\n1DTDw+ZvE66KMaEktpwJsg1pTdMzFBOoi7bHLbagOcW6j4LRKyQe6UvkVg2C\nRQfCJt6W9vuZBXvoHHNgmXnwriIB2/yX2bsKt01Uy0DxiGfNt54EHcSU+t+p\nrJm2psIJNYxoU5pKrpFXIs4VfA4Sb0+pLq13NHEnk2RMcbGqlb9y4oex7rRv\nSQR9DbkPPqrl7yWgp9C/WQJJH+A7s/9NDPWYYrtZvHrGPDoXIcut716AIVIE\nJKbwJ9LEgyhFH/exD7jtftcOMH90+6ZkAP9IpVpBOlprlWoMWgFwJdhEwswC\npfpFZ182tI5cp3SF4mkirWpnbkHOuutHUB4YBWKRMW3XKS9xV4C4Fgynwehe\nXR0pFD45UAVK/855uOFt39m2ZNSDL9PlodBK5H3b+LCr65RzUSf5D6GbiRHf\nMS+c\r\n=d1eb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHUj5qWGJEnFuOj/33yZ9pu+njcI7q3WOvUP3UJ7XC/2AiBoio+8qa9CiJj26NFzb01VdBxYxwDJDxB1uZolGykHaw=="}],"size":9019,"noattachment":false,"key":"/clap/-/clap-3.1.0.tgz"},"_npmUser":{"name":"lahmatiy","email":"rdvornov@gmail.com"},"directories":{},"maintainers":[{"name":"lahmatiy","email":"rdvornov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/clap_3.1.0_1644247451768_0.005626237556753955"},"_hasShrinkwrap":false,"readme":"[![NPM version](https://img.shields.io/npm/v/clap.svg)](https://www.npmjs.com/package/clap)\r\n[![Build Status](https://github.com/lahmatiy/clap/actions/workflows/build.yml/badge.svg)](https://github.com/lahmatiy/clap/actions/workflows/build.yml)\r\n[![Coverage Status](https://coveralls.io/repos/github/lahmatiy/clap/badge.svg?branch=master)](https://coveralls.io/github/lahmatiy/clap?branch=master)\r\n\r\n# Clap.js\r\n\r\nA library for node.js to build command-line interfaces (CLI). With its help, making a simple CLI application is a trivial task. It equally excels in complex tools with a lot of subcommands and specific features. This library supports argument coercion and completion suggestion — typing the commands is much easier.\r\n\r\nInspired by [commander.js](https://github.com/tj/commander.js)\r\n\r\nFeatures:\r\n\r\n- TBD\r\n\r\n## Usage\r\n\r\n```\r\nnpm install clap\r\n```\r\n\r\n```js\r\nconst cli = require('clap');\r\n\r\nconst myCommand = cli.command('my-command [optional-arg]')\r\n    .description('Optional description')\r\n    .version('1.2.3')\r\n    .option('-b, --bool', 'Bollean option')\r\n    .option('--foo <foo>', 'Option with required argument')\r\n    .option('--bar [bar]', 'Option with optional argument')\r\n    .option('--baz [value]', 'Option with optional argument and normalize function',\r\n        value => Number(value),\r\n        123 // 123 is default\r\n    )\r\n    .action(function({ options, args, literalArgs }) {\r\n        // options is an object with collected values\r\n        // args goes before options\r\n        // literal args goes after \"--\"\r\n    });\r\n\r\nmyCommand.run();  // the same as \"myCommnad.run(process.argv.slice(2))\"\r\nmyCommand.run(['--foo', '123', '-b'])\r\n\r\n// sub-commands\r\nmyCommand\r\n    .command('nested')\r\n        .option('-q, --quz', 'Some parameter', 'Default value')\r\n        // ...\r\n        .end()\r\n    .command('another-command [arg1] [arg2]')\r\n        // ...\r\n        .command('level3-command')\r\n            //...\r\n```\r\n\r\n## API\r\n\r\n### Command\r\n\r\n```\r\n.command()\r\n    // definition\r\n    .description(value)\r\n    .version(value, usage, description, action)\r\n    .help(usage, description, action)\r\n    .option(usage, description, ...options)\r\n    .command(usageOrCommand)\r\n    .extend(fn, ...options)\r\n    .end()\r\n\r\n    // argv processing pipeline handler setters\r\n    .init(command, context)\r\n    .applyConfig(context)\r\n    .prerareContenxt(context)\r\n    .action(context)\r\n\r\n    // main methods\r\n    .parse(argv, suggest)\r\n    .run(argv)\r\n\r\n    // misc\r\n    .clone(deep)\r\n    .createOptionValues()\r\n    .getCommand(name)\r\n    .getCommands()\r\n    .getOption(name)\r\n    .getOptions()\r\n    .outputHelp()\r\n```\r\n\r\n### .option(usage, description, ...options)\r\n\r\nThere are two usage:\r\n\r\n```\r\n.option(usage, description, normalize, value)\r\n.option(usage, description, options)\r\n```\r\n\r\nWhere `options`:\r\n\r\n```\r\n{\r\n    default: any,          // default value\r\n    normalize: (value, oldValue) => { ... }, // any value for option is passing through this function and its result stores as option value\r\n    shortcut: (value, oldValue) => { ... },  // for shortcut options, the handler is executed after the value is set, and its result (an object) is used as a source of values for other options\r\n    action: () => { ... }, // for an action option, which breaks regular args processing and preform and action (e.g. show help or version)\r\n    config: boolean        // mark option is about config and should be applied before `applyConfig()`\r\n}\r\n```\r\n\r\n### Argv processing\r\n\r\n- `init(command, context)`  // before arguments parsing\r\n    - invoke action option and exit if any\r\n- apply **config** options\r\n- `applyConfig(context)`\r\n- apply all the rest options\r\n- `prepareContext(context)` // after arguments parsing\r\n    - switch to next command -> command is prescending\r\n        - `init(command, context)`\r\n            - invoke action option and exit if any\r\n        - apply **config** options\r\n        - `applyConfig(context)`\r\n        - apply all the rest options\r\n        - `prepareContext(context)` // after arguments parsing\r\n            - switch to next command\r\n                - ...\r\n            - `action(context)` -> command is target\r\n    - `action(context)` -> command is target\r\n\r\n## License\r\n\r\nMIT\r\n","publish_time":1644247451894,"_cnpm_publish_time":1644247451894,"dist-tags":{"latest":"3.1.1"}}