Skip to content
Myr

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

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

authored by SHAILENDRA SHARMA · committed by SHAILENDRA SHARMA · parent c3ca1f6 · 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
276 unmodified lines
662 , len = argv.length663 , literal664 , option665 , arg;666 667 // if no argv, then check if some required option668 if (len === 0) {669 for (var j = 0, optionLen = this.options.length; j < optionLen; ++j) {670 option = this.options[j];671 if (option.required && option.defaultValue === undefined) {672 return this.optionMissingArgument(option);673 }674 }675 }676677 var unknownOptions = [];678679 // parse options
444 unmodified lines