Repository: yargs/yargs (js)

Issue:
strict seems to overlook parameters in command strings
I'm not sure whether it's my mistake or a misunderstanding but I get errors for sub-command parameters when I enable `strict()` in global mode.

Here's my code:
```js
// index.js
const yargs = require('yargs');

yargs
  .commandDir('./commands')
  .demandCommand(1)
  .strict(true)
  .help()
  .alias('help', 'h')
  .argv;
```

```js
// commands/export.js
exports.command = 'export';
exports.describe = 'export';
exports.builder = yargs => {
  return yargs
    .command('all', 'desc0')
    .command('handed-in [id]', 'desc1')
    .command('by-prop <property> <value>', 'desc2')
    .command('by-reg-nr <regNr>', 'desc3')
    .demandCommand();
};
exports.handler = () => {}
```

When I invoke this script for commands with properties, I keep getting errors:
```bash
$ ./index.js export by-prop 1 2
/usr/bin/nodejs index.js export by-prop <property> <value>

Options:
  --help, -h  show help                                           [boolean]

Unknown arguments: property, value
$ ./index.js export handed-in 1
/usr/bin/nodejs index.js export handed-in [id]

Options:
  --help, -h  show help                                           [boolean]

Unknown argument: id
```
Setting the strict mode in `index.js` to non-global and enabling the strict mode in `command.js` fixes the problem, but why?

Pull request:
fix: positional arguments now work if no handler is provided to inner command
#861 turned out to be due to an edge-case when using inner-commands with no handler; a reasonable fix seems to be to simply default handlers to a noop function when no handler is provided.

fixes #861 

Patch:
diff --git a/.travis.yml b/.travis.yml
index cb31dfc..fbc7109 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,6 @@ os:
 after_success: npm run coverage
 
 node_js:
-  - "0.10"
-  - "0.12"
   - "4"
+  - "6"
   - "node"
diff --git a/appveyor.yml b/appveyor.yml
index 0cb74c6..b51d9dd 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,9 +3,9 @@
 # Test against these versions of Node.js.
 environment:
   matrix:
-    - nodejs_version: "0.10"
     - nodejs_version: "4"
     - nodejs_version: "6"
+    - nodejs_version: "7"
 
 # Install scripts. (runs after repo cloning)
 install:
diff --git a/lib/command.js b/lib/command.js
index d66d288..3567cf9 100644
--- a/lib/command.js
+++ b/lib/command.js
@@ -15,6 +15,8 @@ module.exports = function (yargs, usage, validation) {
   var defaultCommand
   self.addHandler = function (cmd, description, builder, handler) {
     var aliases = []
+    handler = handler || function () {}
+
     if (Array.isArray(cmd)) {
       aliases = cmd.slice(1)
       cmd = cmd[0]


Test patch:
diff --git a/test/command.js b/test/command.js
index d71455a..ef29570 100644
--- a/test/command.js
+++ b/test/command.js
@@ -409,7 +409,7 @@ describe('Command', function () {
       var handlers = y.getCommandInstance().getCommandHandlers()
       handlers.foo.original.should.equal(module.command)
       handlers.foo.builder.should.equal(module.builder)
-      expect(handlers.foo.handler).to.equal(undefined)
+      expect(typeof handlers.foo.handler).to.equal('function')
       var commands = y.getUsageInstance().getCommands()
       commands[0].should.deep.equal([module.command, module.describe, isDefault, aliases])
     })
@@ -1339,4 +1339,18 @@ describe('Command', function () {
         argv._.should.eql(['bar', 'foo'])
       })
   })
+
+  // see: https://github.com/yargs/yargs/issues/861 phew! that's an edge-case.
+  it('should allow positional arguments for inner commands in strict mode, when no handler is provided', () => {
+    yargs()
+      .command('foo', 'outer command', (yargs) => {
+        yargs.command('bar [optional]', 'inner command')
+      })
+      .strict()
+      .parse('foo bar 33', function (err, argv) {
+        expect(err).to.equal(null)
+        argv.optional.should.equal(33)
+        argv._.should.eql(['foo', 'bar'])
+      })
+  })
 })