// matter.js
//

'use strict';

var createError  = require('../createError');
var logErrorExit = require('../logErrorExit');
var pkg = require('../../package.json');

var docopt = require('docopt').docopt;

var doc = `
usage:
  collider matter
  collider matter clone <url> [<locale>]
  collider matter (rm | remove) <locale>

options:
  -h, --help  Show help information.
  --version   Show program version.

commands:
  clone       Clone a Matter library into the current project.
  remove, rm  Remove a Matter library from the current project.

  With no command, 'matter' shows a list of Matter libraries in the current project.
`;

module.exports = function (argv) {
  console.log(argv);

  var args = docopt(doc, {
    argv: argv,
    version: `Collider CLI ${pkg.version}`,
  });

  dispatchOn(['matter', 'clone'], args, matterClone);
  dispatchOn(['matter', 'remove'], args, matterRemove);
  dispatchOn(['matter', 'rm'], args, matterRemove);
};

// FUNCTIONS
//

/**
 * Dispatch a command when the arg vector is truthy in the object docopts provides.
 * @param  {array}    argv  An array of string arguments to match.
 * @param  {object}   args  An object of options, args and commands as keys.
 * @param  {function} cmd   The command handler to call.
 */
function dispatchOn(argv, args, cmd) {
  // ...
  cmd(args);
}

function matterClone(args) {
  console.log('matter clone:', args);
}

function matterRemove(args) {
  console.log('matter remove:', args);
}

@@ -668,29 +668,8 @@
 v) %7B
-%0A  console.log(argv);
 %0A%0A  
@@ -978,16 +978,25 @@
 hen the 
+required 
 arg vect
@@ -1002,20 +1002,15 @@
 tor 
-is truthy in
+matches
  the
@@ -1029,15 +1029,14 @@
 pts 
-provide
+return
 s.%0A 
@@ -1066,45 +1066,31 @@
 gv  
-An array of string arguments to match
+The required arg vector
 .%0A *
@@ -1162,16 +1162,74 @@
  as keys
+, which%0A *                          is provided by docopts
 .%0A * @pa
@@ -1277,16 +1277,26 @@
  to call
+ with args
 .%0A */%0Afu

Update dispatchOn docblock