diff --git a/lib/app.coffee b/lib/app.coffee index f4e9e067..de84d067 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -5,6 +5,8 @@ config = require('./config') yargs = require('yargs') yargs.command = require('./yargs-command/yargs-command') +yargs.usage('$0 [options] ') + # ---------- Auth Module ---------- auth = require('./actions/auth') diff --git a/lib/yargs-command/yargs-command.coffee b/lib/yargs-command/yargs-command.coffee index 1ef6e42e..4f7cafb6 100644 --- a/lib/yargs-command/yargs-command.coffee +++ b/lib/yargs-command/yargs-command.coffee @@ -26,6 +26,8 @@ commandApplies = (command, args) -> return true run = -> + if not @command._matchedCommand? + return console.log(@help()) signature = splitSignature(@command._matchedCommand.signature) parameters = _.difference(@argv._, signature) @command._matchedCommand.action.apply(this, parameters) diff --git a/lib/yargs-command/yargs-command.spec.coffee b/lib/yargs-command/yargs-command.spec.coffee index cd1d14c0..ce1aabbe 100644 --- a/lib/yargs-command/yargs-command.spec.coffee +++ b/lib/yargs-command/yargs-command.spec.coffee @@ -108,3 +108,8 @@ describe 'Yargs Command:', -> yargs.command(COMMANDS.appList.signature, callback) yargs.command.run() expect(callback).to.have.been.calledWith(_.last(ARGS.appList._)) + + it 'should print help if no matches', -> + helpSpy = sinon.spy(yargs, 'help') + yargs.command.run() + expect(helpSpy).to.have.been.called