Skip to content
Myr

Merge pull request #503 from snow01/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

For a required option, when even option flag is not given throw error.

authored by Zhiye Li · committed by GitHub · parents c6236d9, 975e5a4 · Browse files · 3 files+41 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+41 added−2 removed

  • tests:+28 added−2 removed
  • other:+13 added−0 removed

3 files+41 added−2 removed

modified:test/test.arguments.js+2 added-2 removed
added:test/test.options.args.required.no.given.js+26 added
modified:index.js+13 added
374 unmodified lines
375 defaultValue = fn;376 fn = null;377 }378 }379 380 // set default value of the option381 option.defaultValue = defaultValue;382383 // preassign default value only for --no-*, [optional], or <required>384 if (false == option.bool || option.optional || option.required) {385 // when --no-* we make sure default is true
289 unmodified lines
675 , len = argv.length676 , literal677 , option678 , arg;679 680 // if no argv, then check if some required option681 if (len === 0) {682 for (var j = 0, optionLen = this.options.length; j < optionLen; ++j) {683 option = this.options[j];684 if (option.required && option.defaultValue === undefined) {685 return this.optionMissingArgument(option);686 }687 }688 }689690 var unknownOptions = [];691692 // parse options
450 unmodified lines