meteor/meteor — pull request #2718 by mquandalle (2014-09-29 01:09:24+00:00)
Title: Plugin.registerCommand

Hello,

The documentation defines Meteor as two things: a library of packages that aims to provide features to your app, and a command-line tool to build one (or several) app(s) for different targets. Although it's not yet a public thing, there is also the concept of a “plugin” which is a package that extends the command-line tool. Currently the only plugin method is

```js
Plugin.registerSourceHandler(extension, [options], handler)
```

This is used by packages like coffeescript, spacebars, less, stylus, harmony, etc. to auto-compile some specific files and add them to the bundle. This PR introduces a new plugin method:

```js
Plugin.registerCommand(name, [options], action)
```

As the method name says, this method allows packages to register new command-line operations. It will be useful for test systems (velocity), code-generator/scaffolding tools (em), wrapped database administration, etc.

For instance the `em` package could register:

```js
Plugin.registerCommand("em init", function () { /* do something */ });
```

And then a user could simply:

```sh
$ meteor add eventedmind:em
$ meteor em init
```

The exposed API is similar to what is used internally for meteor core commands, and thus allows the same level of features (sub-commands, options...).