Skip to content

Commit

Permalink
Revert "For a required option, when even option flag is not given thr…
Browse files Browse the repository at this point in the history
…ow error."
  • Loading branch information
zhiyelee authored Sep 20, 2016
1 parent 5b396ab commit ce35c35
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 41 deletions.
13 changes: 0 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,6 @@ Command.prototype.option = function(flags, description, fn, defaultValue) {
fn = null;
}
}

// set default value of the option
option.defaultValue = defaultValue;

// preassign default value only for --no-*, [optional], or <required>
if (false == option.bool || option.optional || option.required) {
Expand Down Expand Up @@ -676,16 +673,6 @@ Command.prototype.parseOptions = function(argv) {
, literal
, option
, arg;

// if no argv, then check if some required option
if (len === 0) {
for (var j = 0, optionLen = this.options.length; j < optionLen; ++j) {
option = this.options[j];
if (option.required && option.defaultValue === undefined) {
return this.optionMissingArgument(option);
}
}
}

var unknownOptions = [];

Expand Down
4 changes: 2 additions & 2 deletions test/test.arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ program
cmdValue = cmd;
envValue = env;
})
.option('-C, --chdir [path]', 'change the working directory')
.option('-c, --config [path]', 'set config path. defaults to ./deploy.conf')
.option('-C, --chdir <path>', 'change the working directory')
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
.option('-T, --no-tests', 'ignore test hook');

program.parse(['node', 'test', '--config', 'conf']);
Expand Down
26 changes: 0 additions & 26 deletions test/test.options.args.required.no.given.js

This file was deleted.

0 comments on commit ce35c35

Please sign in to comment.