{"_id":"microcli","_rev":"3645024","name":"microcli","description":"CLI scripts micro engine","dist-tags":{"latest":"1.3.3"},"maintainers":[{"name":"pawelgalazka","email":""}],"time":{"modified":"2024-11-19T02:51:22.000Z","created":"2017-10-22T00:44:02.202Z","1.3.3":"2019-01-19T04:07:49.419Z","1.3.2":"2019-01-11T12:21:18.137Z","1.3.1":"2017-11-06T11:52:32.346Z","1.3.0":"2017-11-06T11:03:47.567Z","1.2.0":"2017-10-30T10:40:44.774Z","1.1.0":"2017-10-28T02:42:58.301Z","1.0.0":"2017-10-22T00:44:02.202Z"},"users":{},"author":{"name":"Pawel Galazka"},"repository":{"type":"git","url":"git+https://github.com/pawelgalazka/microcli.git"},"versions":{"1.3.3":{"name":"microcli","version":"1.3.3","description":"CLI scripts micro engine","main":"./lib/index.js","types":"./lib/index.d.ts","scripts":{"build":"tsc","lint":"tslint -c tslint.json 'src/*.ts'","test":"yarn run lint && yarn run test:unit && yarn build && yarn run test:e2e","test:unit":"jest ./src/index.spec.ts","test:e2e":"jest ./src/index.e2e.spec.ts"},"lint-staged":{"src/*.{ts,tsx}":["tslint --fix","git add","jest --bail --findRelatedTests"]},"engines":{"node":">=6.16.0"},"repository":{"type":"git","url":"git+https://github.com/pawelgalazka/microcli.git"},"keywords":["cli","option","parser","command","commander"],"author":{"name":"Pawel Galazka"},"license":"MIT","bugs":{"url":"https://github.com/pawelgalazka/microcli/issues"},"homepage":"https://github.com/pawelgalazka/microcli#readme","dependencies":{"lodash":"4.17.11","microargs":"1.1.2"},"devDependencies":{"@types/dedent":"0.7.0","@types/jest":"23.3.12","@types/lodash":"4.14.120","@types/node":"10.12.18","dedent":"0.7.0","husky":"1.3.1","jest":"23.6.0","lint-staged":"8.1.0","prettier":"1.15.3","ts-jest":"23.10.5","tslint":"5.12.1","tslint-config-prettier":"1.17.0","tslint-plugin-prettier":"2.0.1","typescript":"3.2.2"},"gitHead":"8e4fb21b0baae4618a30cd69d3f29dceeb822b8d","_id":"microcli@1.3.3","_npmVersion":"6.4.1","_nodeVersion":"10.15.0","_npmUser":{"name":"pawelgalazka","email":"pawel.galazka1986@gmail.com"},"dist":{"shasum":"27f1b330b0f935be6314f298972105a325f731e7","size":73041,"noattachment":false,"key":"/microcli/-/microcli-1.3.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/microcli/download/microcli-1.3.3.tgz"},"maintainers":[{"name":"pawelgalazka","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/microcli_1.3.3_1547870869238_0.4499278402124458"},"_hasShrinkwrap":false,"publish_time":1547870869419,"deprecated":"This project has been renamed to @pawelgalazka/cli . Install using @pawelgalazka/cli instead","_cnpm_publish_time":1547870869419,"_cnpmcore_publish_time":"2021-12-18T23:35:26.729Z"},"1.3.2":{"name":"microcli","version":"1.3.2","description":"CLI scripts micro engine","main":"index.js","scripts":{"test":"yarn run test:lint && yarn run test:unit && yarn run test:e2e","test:lint":"eslint *.js","test:unit":"jest ./test/index.spec.js","test:e2e":"jest ./test/index.e2e.spec.js"},"engines":{"node":">=6.11.1"},"repository":{"type":"git","url":"git+https://github.com/pawelgalazka/microcli.git"},"keywords":["cli","option","parser","command","commander"],"author":{"name":"Pawel Galazka"},"license":"MIT","bugs":{"url":"https://github.com/pawelgalazka/microcli/issues"},"homepage":"https://github.com/pawelgalazka/microcli#readme","dependencies":{"lodash":"4.17.11","microargs":"1.1.1"},"devDependencies":{"dedent":"^0.7.0","eslint":"5.12.0","eslint-config-standard":"12.0.0","eslint-plugin-import":"2.14.0","eslint-plugin-node":"8.0.1","eslint-plugin-promise":"4.0.1","eslint-plugin-standard":"4.0.0","husky":"1.3.1","jest":"23.6.0"},"jest":{"testEnvironment":"node"},"husky":{"hooks":{"pre-commit":"yarn run test:lint"}},"gitHead":"e4f3bae6ddafb2b6d9415c99d1184d5e00123de8","_id":"microcli@1.3.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.0","_npmUser":{"name":"pawelgalazka","email":"pawel.galazka1986@gmail.com"},"dist":{"shasum":"e31b679e27b0c80cf4abbb68cd132ddc86d55602","size":69579,"noattachment":false,"key":"/microcli/-/microcli-1.3.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/microcli/download/microcli-1.3.2.tgz"},"maintainers":[{"name":"pawelgalazka","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/microcli_1.3.2_1547209278007_0.7544540896287215"},"_hasShrinkwrap":false,"publish_time":1547209278137,"_cnpm_publish_time":1547209278137,"_cnpmcore_publish_time":"2021-12-18T23:35:27.102Z"},"1.3.1":{"name":"microcli","version":"1.3.1","description":"CLI scripts micro engine","main":"index.js","scripts":{"test":"yarn run test:lint && yarn run test:unit && yarn run test:e2e","test:lint":"eslint *.js","test:unit":"jest ./test/index.spec.js","test:e2e":"jest ./test/index.e2e.spec.js","precommit":"yarn run test:lint"},"engines":{"node":">=6.11.1"},"repository":{"type":"git","url":"git+https://github.com/pawelgalazka/microcli.git"},"keywords":["cli","option","parser","command","commander"],"author":{"name":"Pawel Galazka"},"license":"MIT","bugs":{"url":"https://github.com/pawelgalazka/microcli/issues"},"homepage":"https://github.com/pawelgalazka/microcli#readme","dependencies":{"lodash":"4.17.4","microargs":"1.1.0"},"devDependencies":{"dedent":"^0.7.0","eslint":"4.9.0","eslint-config-standard":"10.2.1","eslint-plugin-import":"2.8.0","eslint-plugin-node":"5.2.0","eslint-plugin-promise":"3.6.0","eslint-plugin-standard":"3.0.1","husky":"0.14.3","jest":"21.2.1"},"jest":{"testEnvironment":"node"},"gitHead":"c3a8538b0d243d9dc0d3ffe6f55295fa6562754e","_id":"microcli@1.3.1","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"pawelgalazka","email":"pawel.galazka1986@gmail.com"},"dist":{"shasum":"6e49b71a545be7916a87b9edd3bae68cc85d67cc","size":36609,"noattachment":false,"key":"/microcli/-/microcli-1.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/microcli/download/microcli-1.3.1.tgz"},"maintainers":[{"name":"pawelgalazka","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/microcli-1.3.1.tgz_1509969152075_0.4128682871814817"},"directories":{},"publish_time":1509969152346,"_hasShrinkwrap":false,"_cnpm_publish_time":1509969152346,"_cnpmcore_publish_time":"2021-12-18T23:35:27.338Z"},"1.3.0":{"name":"microcli","version":"1.3.0","description":"CLI scripts micro engine","main":"index.js","scripts":{"test":"yarn run test:lint && yarn run test:unit && yarn run test:e2e","test:lint":"eslint *.js","test:unit":"jest ./test/index.spec.js","test:e2e":"jest ./test/index.e2e.spec.js","precommit":"yarn run test:lint"},"engines":{"node":">=6.11.1"},"repository":{"type":"git","url":"git+https://github.com/pawelgalazka/microcli.git"},"keywords":["cli","option","parser","command","commander"],"author":{"name":"Pawel Galazka"},"license":"MIT","bugs":{"url":"https://github.com/pawelgalazka/microcli/issues"},"homepage":"https://github.com/pawelgalazka/microcli#readme","dependencies":{"lodash":"4.17.4","microargs":"1.1.0"},"devDependencies":{"dedent":"^0.7.0","eslint":"4.9.0","eslint-config-standard":"10.2.1","eslint-plugin-import":"2.8.0","eslint-plugin-node":"5.2.0","eslint-plugin-promise":"3.6.0","eslint-plugin-standard":"3.0.1","husky":"0.14.3","jest":"21.2.1"},"jest":{"testEnvironment":"node"},"gitHead":"7d008cba37e87cd468b40f690a8cfb133a7e116a","_id":"microcli@1.3.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"pawelgalazka","email":"pawel.galazka1986@gmail.com"},"dist":{"shasum":"0ea4fa174ee54fa8b8682296260f66a2a4865711","size":36282,"noattachment":false,"key":"/microcli/-/microcli-1.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/microcli/download/microcli-1.3.0.tgz"},"maintainers":[{"name":"pawelgalazka","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/microcli-1.3.0.tgz_1509966227386_0.5196684168186039"},"directories":{},"publish_time":1509966227567,"_hasShrinkwrap":false,"_cnpm_publish_time":1509966227567,"_cnpmcore_publish_time":"2021-12-18T23:35:27.591Z"},"1.2.0":{"name":"microcli","version":"1.2.0","description":"CLI scripts micro engine","main":"index.js","scripts":{"test":"yarn run test:lint && yarn run test:unit && yarn run test:e2e","test:lint":"eslint *.js","test:unit":"jest ./test/index.spec.js","test:e2e":"jest ./test/index.e2e.spec.js","precommit":"yarn run test:lint"},"engines":{"node":">=6.11.1"},"repository":{"type":"git","url":"git+https://github.com/pawelgalazka/microcli.git"},"keywords":["cli","option","parser","command","commander"],"author":{"name":"Pawel Galazka"},"license":"MIT","bugs":{"url":"https://github.com/pawelgalazka/microcli/issues"},"homepage":"https://github.com/pawelgalazka/microcli#readme","dependencies":{"lodash":"4.17.4","microargs":"1.1.0"},"devDependencies":{"dedent":"^0.7.0","eslint":"4.9.0","eslint-config-standard":"10.2.1","eslint-plugin-import":"2.8.0","eslint-plugin-node":"5.2.0","eslint-plugin-promise":"3.6.0","eslint-plugin-standard":"3.0.1","husky":"0.14.3","jest":"21.2.1"},"jest":{"testEnvironment":"node"},"gitHead":"cbef962359f02a04257b9ecc9627d2faa3627816","_id":"microcli@1.2.0","_shasum":"001256e09746c03a68f52c739d48289c98a98246","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"pawelgalazka","email":"pawel.galazka1986@gmail.com"},"dist":{"shasum":"001256e09746c03a68f52c739d48289c98a98246","size":35067,"noattachment":false,"key":"/microcli/-/microcli-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/microcli/download/microcli-1.2.0.tgz"},"maintainers":[{"name":"pawelgalazka","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/microcli-1.2.0.tgz_1509360044573_0.36842904426157475"},"directories":{},"publish_time":1509360044774,"_hasShrinkwrap":false,"_cnpm_publish_time":1509360044774,"_cnpmcore_publish_time":"2021-12-18T23:35:27.949Z"},"1.1.0":{"name":"microcli","version":"1.1.0","description":"CLI scripts micro engine","main":"index.js","scripts":{"test":"yarn run test:lint && yarn run test:unit && yarn run test:e2e","test:lint":"eslint *.js","test:unit":"jest","test:e2e":"./test/index.e2e.js -a --foo=bar abc def","precommit":"yarn run test:lint"},"engines":{"node":">=6.11.1"},"repository":{"type":"git","url":"git+https://github.com/pawelgalazka/microcli.git"},"keywords":["cli","option","parser","command","commander"],"author":{"name":"Pawel Galazka"},"license":"MIT","bugs":{"url":"https://github.com/pawelgalazka/microcli/issues"},"homepage":"https://github.com/pawelgalazka/microcli#readme","dependencies":{"lodash":"4.17.4","microargs":"1.1.0"},"devDependencies":{"eslint":"4.9.0","eslint-config-standard":"10.2.1","eslint-plugin-import":"2.8.0","eslint-plugin-node":"5.2.0","eslint-plugin-promise":"3.6.0","eslint-plugin-standard":"3.0.1","husky":"0.14.3","jest":"21.2.1"},"jest":{"testEnvironment":"node"},"gitHead":"c53f04896ce3fc9e00a67e021c723b89d2b0eeaf","_id":"microcli@1.1.0","_shasum":"9492038c0bb6aee7f25aff797424608ea6187bcd","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"pawelgalazka","email":"pawel.galazka1986@gmail.com"},"dist":{"shasum":"9492038c0bb6aee7f25aff797424608ea6187bcd","size":34849,"noattachment":false,"key":"/microcli/-/microcli-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/microcli/download/microcli-1.1.0.tgz"},"maintainers":[{"name":"pawelgalazka","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/microcli-1.1.0.tgz_1509158578189_0.595098044257611"},"directories":{},"publish_time":1509158578301,"_hasShrinkwrap":false,"_cnpm_publish_time":1509158578301,"_cnpmcore_publish_time":"2021-12-18T23:35:28.215Z"},"1.0.0":{"name":"microcli","version":"1.0.0","description":"CLI scripts micro engine","main":"index.js","scripts":{"test":"yarn run test:lint && yarn run test:unit","test:lint":"eslint *.js","test:unit":"jest"},"engines":{"node":">=6.11.1"},"repository":{"type":"git","url":"git+https://github.com/pawelgalazka/microcli.git"},"keywords":["cli","option","parser","command","commander"],"author":{"name":"Pawel Galazka"},"license":"MIT","bugs":{"url":"https://github.com/pawelgalazka/microcli/issues"},"homepage":"https://github.com/pawelgalazka/microcli#readme","dependencies":{"microargs":"1.1.0"},"devDependencies":{"eslint":"4.9.0","eslint-config-standard":"10.2.1","eslint-plugin-import":"2.8.0","eslint-plugin-node":"5.2.0","eslint-plugin-promise":"3.6.0","eslint-plugin-standard":"3.0.1","jest":"21.2.1"},"gitHead":"e9525e750f19dbdecc58b55026f8adfe31bd4a64","_id":"microcli@1.0.0","_shasum":"deeb8a2368c9117c9b773a3c8ef7c57fc4c8e8ea","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"pawelgalazka","email":"pawel.galazka1986@gmail.com"},"dist":{"shasum":"deeb8a2368c9117c9b773a3c8ef7c57fc4c8e8ea","size":33251,"noattachment":false,"key":"/microcli/-/microcli-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/microcli/download/microcli-1.0.0.tgz"},"maintainers":[{"name":"pawelgalazka","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/microcli-1.0.0.tgz_1508633042096_0.6276976284570992"},"directories":{},"publish_time":1508633042202,"_hasShrinkwrap":false,"_cnpm_publish_time":1508633042202,"_cnpmcore_publish_time":"2021-12-18T23:35:28.448Z"}},"readme":"# microcli ![node version](https://img.shields.io/node/v/microcli.svg) [![Build Status](https://travis-ci.org/pawelgalazka/microcli.svg?branch=master)](https://travis-ci.org/pawelgalazka/microcli) [![npm version](https://badge.fury.io/js/microcli.svg)](https://badge.fury.io/js/microcli)\nCLI scripts micro engine\n\n```js\n#!/usr/bin/env node\nconst microcli = require('microcli')\nconst cli = microcli(process.argv, 'Script doc');\ncli((options, p1, p2) => {\n    console.log('OPTIONS', options)\n    console.log('P1', p1)\n    console.log('P2', p2)\n})\n```\n\n```\n$ script.js -a --foo=bar --boo abc def\nOPTIONS {a: true, foo: 'bar', boo: true }\nP1 abc\nP2 def\n\n$ script.js --help\nUsage: script.js\n\nScript doc\n```\n\n### Annotations\n\n```js\n#!/usr/bin/env node\nconst microcli = require('microcli')\nconst cli = microcli(process.argv, {\n  description: 'Basic script description',\n  params: ['p1', 'p2'],\n  options: {\n    a: 'description for a option',\n    foo: 'description for foo option'\n  },\n  examples: 'some examples'\n});\n\ncli((options, p1, p2) => {\n    console.log('OPTIONS', options)\n    console.log('P1', p1)\n    console.log('P2', p2)\n})\n```\n\n```\n$ script.js --help\nUsage: script.js [options] [p1 p2]\n\nBasic script description\n\nOptions:\n\n    -a         description for a option\n    --foo      description for foo option\n    \nExamples:\n\nsome examples\n```\n\nAnnotations plays part also in validating process. So if\noption which does not exist in annotations is provided, `microcli` will\nthrow an error:\n\n```\n$ script.js --bar\nIllegal option: --bar\nAvailable options: -a --foo\nType \"script.js --help\" for more information\n```\n\nAlso each annotation is optional and custom annotations like `examples`\n(basically other than description, params and options) will be treated\nin `--help` content as additional header with string value.\n\n### Commands\n```\n$ script.js status --foo abc \nOPTIONS {foo: true}\nP abc\n\n$ script.js branch --help\nUsage: branch [options] [p]\n\nBasic script description\n\n$ script.js --foo abc\nOPTIONS {foo: true}\nP abc\n\n```\n\n```js\n#!/usr/bin/env node\nconst microcli = require('microcli')\n\nconst main = microcli(process.argv, {\n  description: 'base command',\n  params: ['p'],\n  options: {\n    foo: 'foo option'\n  }\n})\n\nconst status = microcli(process.argv.slice(1), {\n  description: 'Fake git status',\n  params: ['p'],\n  options: {\n    foo: 'foo option'\n  }\n})\n\nconst branch = microcli(process.argv.slice(1), {\n  description: 'Fake git branch',\n  params: ['p'],\n  options: {\n    foo: 'foo option'\n  }\n})\n\nswitch (process.argv[2]) {\n  case 'status':\n    status((options, p) => {\n      console.log('OPTIONS', options)\n      console.log('P', p)\n    })\n    break\n\n  case 'branch':\n    branch((options, p) => {\n      console.log('OPTIONS', options)\n      console.log('P', p)\n    })\n    break\n\n  default:\n    main((options, p) => {\n      console.log('OPTIONS', options)\n      console.log('P', p)\n    })\n}\n```\n\n### Custom --help\n\nYou can provide `help` function to `cli` call, which can generate\ncustom help message, having annotations object:\n\n```js\n#!/usr/bin/env node\nconst microcli = require('microcli')\nconst cli = microcli(process.argv, {\n  /* some annotations */\n}, (scriptName, annotations, logger) => {\n  logger.log('Custom --help message') \n});\n\ncli((options, p1, p2) => {\n    console.log('OPTIONS', options)\n    console.log('P1', p1)\n    console.log('P2', p2)\n})\n```\n","_attachments":{},"homepage":"https://github.com/pawelgalazka/microcli#readme","bugs":{"url":"https://github.com/pawelgalazka/microcli/issues"},"license":"MIT"}