diff --git a/index.js b/index.js index eebaec03a..3ad0cacfd 100644 --- a/index.js +++ b/index.js @@ -660,7 +660,8 @@ Command.prototype.parseArgs = function(args, unknown) { if (unknown.length > 0) { this.unknownOption(unknown[0]); } - if (this._args.filter(a => a.required).length === 0) { + if (this.commands.length === 0 && + this._args.filter(function(a) { return a.required }).length === 0) { this.emit('command:*'); } } diff --git a/test/test.commandAsterisk.action.js b/test/test.commandAsterisk.action.js new file mode 100644 index 000000000..d72381054 --- /dev/null +++ b/test/test.commandAsterisk.action.js @@ -0,0 +1,15 @@ +var program = require('../') + , should = require('should'); + +var val = false; +program + .version('0.0.1') + .command('*') + .description('test') + .action(function () { + val = true; + }); + +program.parse(['node', 'test']); + +val.should.be.false()