Skip to content

Commit

Permalink
Fix #143 - run gulp build
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbrokke committed Jun 22, 2016
1 parent 96562e4 commit 4abd458
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
18 changes: 18 additions & 0 deletions dist/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Command(name, parent) {
this._help = undefined;
this._init = undefined;
this._after = undefined;
this._allowUnknownOptions = false;
}

/**
Expand Down Expand Up @@ -366,6 +367,23 @@ command.hidden = function () {
return this;
};

/**
* Allows undeclared options to be passed in with the command.
*
* @param {Boolean} [allowUnknownOptions=true]
* @return {Command}
* @api public
*/

command.allowUnknownOptions = function () {
var allowUnknownOptions = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];

allowUnknownOptions = allowUnknownOptions === "false" ? false : allowUnknownOptions;

this._allowUnknownOptions = !!allowUnknownOptions;
return this;
};

/**
* Returns the command usage string for help.
*
Expand Down
14 changes: 10 additions & 4 deletions dist/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ var util = {
}

// Looks for supplied options that don't
// exist in the options list and throws help
// exist in the options list.
// If the command allows unknown options,
// adds it, otherwise throws help.
var passedOpts = _.chain(parsedArgs).keys().pull('_').pull('help').value();

var _loop = function _loop(key) {
Expand All @@ -316,9 +318,13 @@ var util = {
return false;
});
if (optionFound === undefined) {
return {
v: '\n Invalid option: \'' + opt + '\'. Showing Help:'
};
if (cmd._allowUnknownOptions) {
args.options[opt] = parsedArgs[opt];
} else {
return {
v: '\n Invalid option: \'' + opt + '\'. Showing Help:'
};
}
}
};

Expand Down

0 comments on commit 4abd458

Please sign in to comment.