Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complain about unknown options if there are >0 arguments on command line #965

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -653,7 +653,7 @@ Command.prototype.parseArgs = function(args, unknown) {
if (this.listeners('command:' + name).length) {
this.emit('command:' + args.shift(), args, unknown);
} else {
this.emit('command:*', args);
this.emit('command:*', args, unknown);
}
} else {
outputHelpIfNecessary(this, unknown);
Expand Down
11 changes: 11 additions & 0 deletions test/test.arguments.js
Expand Up @@ -7,6 +7,7 @@ var program = require('../')

var envValue = "";
var cmdValue = "";
var optionsValue = {};

program
.version('0.0.1')
Expand All @@ -19,6 +20,15 @@ program
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
.option('-T, --no-tests', 'ignore test hook');

program
.command("setup [env]")
.option("--setup_mode <mode>", "the setup mode")
.action(function (env, options) {
cmdValue = "setup";
envValue = env;
optionsValue = options
})

program.parse(['node', 'test', '--config', 'conf']);
program.config.should.equal("conf");
cmdValue.should.equal("");
Expand All @@ -28,3 +38,4 @@ program.parse(['node', 'test', '--config', 'conf1', 'setup', '--setup_mode', 'mo
program.config.should.equal("conf1");
cmdValue.should.equal("setup");
envValue.should.equal("env1");
optionsValue.setup_mode.should.equal("mode3");