Skip to content
Myr

Merge pull request #311 from zhiyelee/subcommanduk

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

subcommand allowUnknown option

authored by Zhiye Li · committed by Zhiye Li · parents 2c013fa, d71d471 · Browse files · 3 files+57 added−39 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+57 added−39 removed

  • tests:+55 added−38 removed
  • other:+2 added−1 removed

3 files+57 added−39 removed

added:test/test.options.allowUnknown.js+55 added
deleted:test/test.options.unknown.js-38 removed
modified:index.js+2 added-1 removed
545 unmodified lines
546 outputHelpIfNecessary(this, unknown);547548 // If there were no args and we have unknown options,549 // then they are extraneous and we need to error.550 if (!this._allowUnknown && unknown.length > 0) {550 if (unknown.length > 0) {551 this.unknownOption(unknown[0]);552 }553 }554
152 unmodified lines
707 * @api private708 */709710Command.prototype.unknownOption = function(flag) {711 if(this._allowUnknown) return;712 console.error();713 console.error(" error: unknown option `%s'", flag);714 console.error();715 process.exit(1);
284 unmodified lines