{"_id":"subcommand","_rev":"93202","name":"subcommand","description":"create CLI tools with subcommands","dist-tags":{"latest":"2.1.1"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"time":{"modified":"2021-06-03T10:30:56.000Z","created":"2015-04-05T03:59:35.581Z","2.1.1":"2019-03-01T17:47:09.272Z","2.1.0":"2017-01-18T22:57:57.721Z","2.0.4":"2016-10-14T05:16:55.408Z","2.0.3":"2015-08-25T17:25:13.394Z","2.0.2":"2015-06-12T17:57:14.275Z","2.0.1":"2015-04-07T18:13:27.596Z","2.0.0":"2015-04-07T18:02:48.067Z","1.1.1":"2015-04-07T04:42:30.316Z","1.1.0":"2015-04-06T23:44:43.163Z","1.0.1":"2015-04-05T04:02:01.051Z","1.0.0":"2015-04-05T03:59:35.581Z"},"users":{"julien-f":true,"ctesniere":true},"author":{"name":"max ogden"},"repository":{"type":"git","url":"git+https://github.com/maxogden/subcommand.git"},"versions":{"2.1.1":{"name":"subcommand","version":"2.1.1","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"git+https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD-2-Clause","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^4.1.1","minimist":"^1.2.0"},"devDependencies":{"standard":"^12.0.1","tape":"^4.0.0"},"gitHead":"5248f6f7cd44dbfe09928d1f1ff98f4b682683e4","_id":"subcommand@2.1.1","_nodeVersion":"10.2.1","_npmVersion":"6.8.0","dist":{"shasum":"66ba790cc72564049eface644c4a24291a4829c7","size":4830,"noattachment":false,"key":"/subcommand/-/subcommand-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-2.1.1.tgz"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"_npmUser":{"name":"jhand","email":"joe@hand.email"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/subcommand_2.1.1_1551462429155_0.5090764485243522"},"_hasShrinkwrap":false,"publish_time":1551462429272,"_cnpm_publish_time":1551462429272},"2.1.0":{"name":"subcommand","version":"2.1.0","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"git+https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD-2-Clause","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.2.0","xtend":"^4.0.0"},"devDependencies":{"standard":"^3.3.2","tape":"^4.0.0"},"gitHead":"6b9bdab1097dfe5cf3bf56c31b164e8de2c5546c","_id":"subcommand@2.1.0","_shasum":"5e4ceca5a3779e3365b1511e05f866877302f760","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"jhand","email":"joe@hand.email"},"dist":{"shasum":"5e4ceca5a3779e3365b1511e05f866877302f760","size":5089,"noattachment":false,"key":"/subcommand/-/subcommand-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-2.1.0.tgz"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/subcommand-2.1.0.tgz_1484780275948_0.4761809688061476"},"directories":{},"publish_time":1484780277721,"_cnpm_publish_time":1484780277721,"_hasShrinkwrap":false},"2.0.4":{"name":"subcommand","version":"2.0.4","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"git+https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD-2-Clause","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.2.0","xtend":"^4.0.0"},"devDependencies":{"standard":"^3.3.2","tape":"^4.0.0"},"gitHead":"b0fcb7b3858aadcdc2e921ddc96c73326cb4f0da","_id":"subcommand@2.0.4","_shasum":"71cd54bd83a78a0b266296cda3f9428e91d66b14","_from":".","_npmVersion":"2.14.15","_nodeVersion":"4.2.3","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"dist":{"shasum":"71cd54bd83a78a0b266296cda3f9428e91d66b14","size":4222,"noattachment":false,"key":"/subcommand/-/subcommand-2.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-2.0.4.tgz"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/subcommand-2.0.4.tgz_1476422215183_0.25847367220558226"},"directories":{},"publish_time":1476422215408,"_cnpm_publish_time":1476422215408,"_hasShrinkwrap":false},"2.0.3":{"name":"subcommand","version":"2.0.3","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"git+https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.2.0","xtend":"^4.0.0"},"devDependencies":{"standard":"^3.3.2","tape":"^4.0.0"},"gitHead":"b7e2901afddec02ec2c9361a9d39bd785e10e329","_id":"subcommand@2.0.3","_shasum":"9b3fd1a753e3c441f00410cb44131d8655f52c32","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"dist":{"shasum":"9b3fd1a753e3c441f00410cb44131d8655f52c32","size":3457,"noattachment":false,"key":"/subcommand/-/subcommand-2.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-2.0.3.tgz"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"directories":{},"publish_time":1440523513394,"_cnpm_publish_time":1440523513394,"_hasShrinkwrap":false},"2.0.2":{"name":"subcommand","version":"2.0.2","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"git+https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.1.1","xtend":"^4.0.0"},"devDependencies":{"standard":"^3.3.2","tape":"^4.0.0"},"gitHead":"eedf5dccaef8ce9895834c8292605c7ccb19eeb6","_id":"subcommand@2.0.2","_shasum":"ead494c778452374d74189ed32a9291c1a68350a","_from":".","_npmVersion":"2.9.0","_nodeVersion":"1.8.2","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"dist":{"shasum":"ead494c778452374d74189ed32a9291c1a68350a","size":3275,"noattachment":false,"key":"/subcommand/-/subcommand-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-2.0.2.tgz"},"directories":{},"publish_time":1434131834275,"_cnpm_publish_time":1434131834275,"_hasShrinkwrap":false},"2.0.1":{"name":"subcommand","version":"2.0.1","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.1.1","xtend":"^4.0.0"},"devDependencies":{"standard":"^3.3.2","tape":"^4.0.0"},"gitHead":"0cbb92aca86bb81fa92ab042fb7b73301f990e57","_id":"subcommand@2.0.1","_shasum":"1b9fd534a0311a05030f118c6b546a23ccac2431","_from":".","_npmVersion":"2.7.0","_nodeVersion":"1.5.1","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"dist":{"shasum":"1b9fd534a0311a05030f118c6b546a23ccac2431","size":3287,"noattachment":false,"key":"/subcommand/-/subcommand-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-2.0.1.tgz"},"directories":{},"publish_time":1428430407596,"_cnpm_publish_time":1428430407596,"_hasShrinkwrap":false},"2.0.0":{"name":"subcommand","version":"2.0.0","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.1.1","xtend":"^4.0.0"},"devDependencies":{"standard":"^3.3.2","tape":"^4.0.0"},"gitHead":"39d66ee8766945bcb97757eea30ba5e2b64a46d2","_id":"subcommand@2.0.0","_shasum":"0bff42ffa3ccf777368a217de265a8a04e9c33d5","_from":".","_npmVersion":"2.7.0","_nodeVersion":"1.5.1","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"dist":{"shasum":"0bff42ffa3ccf777368a217de265a8a04e9c33d5","size":3237,"noattachment":false,"key":"/subcommand/-/subcommand-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-2.0.0.tgz"},"directories":{},"publish_time":1428429768067,"_cnpm_publish_time":1428429768067,"_hasShrinkwrap":false},"1.1.1":{"name":"subcommand","version":"1.1.1","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.1.1","xtend":"^4.0.0"},"devDependencies":{"standard":"^3.3.2","tape":"^4.0.0"},"gitHead":"5c3be69ba133eea58784e90b905f8260c4f4d84c","_id":"subcommand@1.1.1","_shasum":"c6c2e11a85906f8853470d4b8f40dda7cc8e1e00","_from":".","_npmVersion":"2.7.0","_nodeVersion":"1.5.1","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"dist":{"shasum":"c6c2e11a85906f8853470d4b8f40dda7cc8e1e00","size":2558,"noattachment":false,"key":"/subcommand/-/subcommand-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-1.1.1.tgz"},"directories":{},"publish_time":1428381750316,"_cnpm_publish_time":1428381750316,"_hasShrinkwrap":false},"1.1.0":{"name":"subcommand","version":"1.1.0","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.1.1","xtend":"^4.0.0"},"devDependencies":{"standard":"^3.3.2","tape":"^4.0.0"},"gitHead":"9c07713fdda2af499683673534497d83618f9384","_id":"subcommand@1.1.0","_shasum":"44cc106575733113cc2da8328d0d7528a3533904","_from":".","_npmVersion":"2.7.0","_nodeVersion":"1.5.1","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"dist":{"shasum":"44cc106575733113cc2da8328d0d7528a3533904","size":2548,"noattachment":false,"key":"/subcommand/-/subcommand-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-1.1.0.tgz"},"directories":{},"publish_time":1428363883163,"_cnpm_publish_time":1428363883163,"_hasShrinkwrap":false},"1.0.1":{"name":"subcommand","version":"1.0.1","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.1.1"},"devDependencies":{"standard":"^3.3.2"},"gitHead":"b5bc54c9d25218abcf3bff5f7040360dfcd6fcb8","_id":"subcommand@1.0.1","_shasum":"aa2e7286df19da6fa9255446ec16c6bfb3e4a6b5","_from":".","_npmVersion":"2.7.0","_nodeVersion":"1.5.1","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"dist":{"shasum":"aa2e7286df19da6fa9255446ec16c6bfb3e4a6b5","size":2202,"noattachment":false,"key":"/subcommand/-/subcommand-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-1.0.1.tgz"},"directories":{},"publish_time":1428206521051,"_cnpm_publish_time":1428206521051,"_hasShrinkwrap":false},"1.0.0":{"name":"subcommand","version":"1.0.0","description":"create CLI tools with subcommands","main":"index.js","scripts":{"test":"standard && node test.js"},"repository":{"type":"git","url":"https://github.com/maxogden/subcommand.git"},"keywords":["minimist"],"author":{"name":"max ogden"},"license":"BSD","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"homepage":"https://github.com/maxogden/subcommand","dependencies":{"cliclopts":"^1.1.0","debug":"^2.1.3","minimist":"^1.1.1"},"gitHead":"a69f8392f6df78ca049b6d262e460e183c38c26a","_id":"subcommand@1.0.0","_shasum":"fe073d7b74830b13b232c82b3faa4f8ac95435c9","_from":".","_npmVersion":"2.7.0","_nodeVersion":"1.5.1","_npmUser":{"name":"maxogden","email":"max@maxogden.com"},"maintainers":[{"name":"jhand","email":"joe@joeahand.com"},{"name":"karissa","email":"krmckelv@gmail.com"}],"dist":{"shasum":"fe073d7b74830b13b232c82b3faa4f8ac95435c9","size":2195,"noattachment":false,"key":"/subcommand/-/subcommand-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/subcommand/download/subcommand-1.0.0.tgz"},"directories":{},"publish_time":1428206375581,"_cnpm_publish_time":1428206375581,"_hasShrinkwrap":false}},"readme":"# subcommand\n\nCreate CLI tools with subcommands. A minimalist CLI router based on [minimist](https://www.npmjs.com/package/minimist) and [cliclopts](https://www.npmjs.com/package/cliclopts).\n\n[![NPM](https://nodei.co/npm/subcommand.png)](https://nodei.co/npm/subcommand/)\n\n[![js-standard-style](https://raw.githubusercontent.com/feross/standard/master/badge.png)](https://github.com/feross/standard)\n\n[![Build Status](https://travis-ci.org/maxogden/subcommand.svg?branch=master)](https://travis-ci.org/maxogden/subcommand)\n\n## basic usage\n\nfirst, define your CLI API in JSON like this:\n\n```js\nvar commands = [\n  {\n    name: 'foo',\n    options: [ // cliclopts options\n      {\n        name: 'loud',\n        boolean: true,\n        default: false,\n        abbr: 'v',\n        help: 'print out all output loudly'\n      }\n    ],\n    command: function foo (args) {\n      // called when `foo` is matched\n    }\n  },\n  {\n    name: 'bar',\n    command: function bar (args) {\n      // called when `bar` is matched\n    }\n  }\n]\n```\n\nthen pass them into `subcommand`:\n\n```js\nvar subcommand = require('subcommand')\nvar match = subcommand(config, opts)\n```\n\n`subcommand` returns a function (called `match` above) that you can use to match/route arguments to their subcommands\n\nthe return value will be `true` if a subcommand was matched, or `false` if no subcommand was matched\n\n```js\nvar matched = match(['foo'])\n// matched will be true, and foo's `command` function will be called\n\nvar matched = match(['foo', 'baz', 'taco'])\n// matched will be true, and foo's `command` function will be called with `['baz', 'taco']`\n\nvar matched = match(['bar'])\n// matched will be true, and bar's `command` function will be called\n\nvar matched = match(['uhoh'])\n// matched will be false\n```\n\n## advanced usage\n\ninstead of an array, you can also pass an object that looks like this as the first argument to `subcommand`:\n\n```\n{\n  root: // root command options and handler\n  defaults: // default options\n  all: // function that gets called always, regardless of match or no match\n  none: // function that gets called only when there is no matched subcommand\n  usage: // subcommand to use for printing usage\n  commands: // the commands array from basic usage\n}\n```\n\nsee `test.js` for a concrete example\n\n### root\n\nto pass options to the 'root' command (e.g. when no subcommand is passed in), set up your config like this:\n\n```js\nvar config = {\n  root: {\n    options: [ // cliclopts options\n      {\n        name: 'loud',\n        boolean: true,\n        default: false,\n        abbr: 'v'\n      }\n    ],\n    command: function (args) {\n      // called when no subcommand is specified\n    }\n  },\n  commands: yourSubCommandsArray\n}\n```\n\n### defaults\n\nyou can pass in a defaults options array, and all subcommands as well as the root command will inherit the default options\n\n```js\nvar config = {\n  defaults: [\n    {name: 'path', default: process.cwd()} // all commands (and root) will now always have a 'path' default option\n  ],\n  commands: yourSubCommandsArray\n}\n```\n\n### all\n\npass a function under the `all` key and it will get called with the parsed arguments 100% of the time\n\n```js\nvar config = {\n  all: function all (args) { /** will be called always in addition to the command/root `command` handlers **/ },\n  commands: yourSubCommandsArray\n}\n```\n\n### none\n\npass a function under the `none` key and it will get called when no subcommand is matched\n\n```js\nvar config = {\n  none: function none (args) { /** will only be called when no subcommand is matched **/ },\n  commands: yourSubCommandsArray\n}\n```\n\n### usage\n\nThe `usage` option makes it easy to print [cliclops usage](https://github.com/finnp/cliclopts#clioptsusage) for the root command and subcommands.\n\n#### Basic usage\n\nBy default, usage is printed with the `--help` or `-h` option. Set usage to true to print `cliclops.usage()` with `--help`:\n\n```js\nvar config = {\n  usage: true\n}\n```\n\nUse `usage.help` to print information above `cliclops.usage()`. Change the name of the usage option by specifying `usage.option`:\n\n```js\nvar config = {\n  usage: {\n    help: 'general usage info',\n    option: {\n      name: 'info',\n      abbr: 'i'\n    }\n  }\n}\n```\n\nThis will print the usage with `--info` or `-i` instead of `--help`. The option is used for the root and subcommands.\n\n#### Advanced Usage\n\nYou can also define custom usage functions for the root and subcommands. These are passed the help text and `cliclops.usage()`.\n\n```js\nvar config = {\n  usage: {\n    help: 'general help message', // Message to print before cliclops.usage()\n    option: {\n      // minimist option to use for printing usage\n      name: 'help',\n      abbr: 'h'\n    },\n    command: function (args, help, usage) {\n      // optional function to print usage. \n      console.log(help) // prints: \"general help message\"\n      console.log(usage) // prints: cliclops.usage() \n    }\n  },\n  commands: [{\n    name: 'foo',\n    help: 'foo help message',\n    options: [\n      {\n        name: 'loud',\n        help: 'print out all output loudly'\n      }\n    ],\n    usage: function (args, help, usage) {\n      // called when `foo` is matched and --help option is used\n      console.log(help) // prints: \"foo help message\"\n      console.log(usage) // prints: cliclops.usage()\n    },\n    command: function foo (args) {\n      // called when `foo` is matched\n    }\n  }]\n}\n```\n","_attachments":{},"homepage":"https://github.com/maxogden/subcommand","bugs":{"url":"https://github.com/maxogden/subcommand/issues"},"license":"BSD-2-Clause"}