diff --git a/bin/documentation.js b/bin/documentation.js index 78ddee0..c0b74a0 100755 --- a/bin/documentation.js +++ b/bin/documentation.js @@ -67,6 +67,13 @@ function parseArgs() { var command = argv._[0], inputs = argv._.slice(1); + if (!commands[command]) { + yargs.showHelp(); + var suggestion = [argv['$0'], 'build'].concat(process.argv.slice(2)).join(' '); + process.stderr.write('Unknown command: ' + command + '. Did you mean "' + suggestion + '"?\n'); + process.exit(1); + } + if (inputs.length == 0) { try { var p = require(path.resolve('package.json')); diff --git a/test/bin.js b/test/bin.js index c4273df..82b60c4 100644 --- a/test/bin.js +++ b/test/bin.js @@ -122,6 +122,14 @@ test('invalid arguments', function (group) { }); }, options); + group.test('bad command', function (t) { + documentation(['-f html fixture/internal.input.js'], function (err, stdout, stderr) { + t.ok(err.code, 'exits nonzero'); + t.ok(stderr.match(/Unknown command/), 'reports unknown command'); + t.end(); + }); + }); + group.end(); });