Skip to content
Browse files

Allow a mode that does not throw if unrecognized flags are encountere…

…d during parsing
  • Loading branch information...
1 parent ebfb8ab commit 26dd3f0453c8555c2b361261ff05e67517214251 @dpup committed
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/flags.js
View
6 lib/flags.js
@@ -157,8 +157,10 @@ exports.get = function(name) {
* Parses process.argv for flags. Idempotent if called multiple times.
* @param {Array.<string>=} opt_args Optional arguments array to use instead of
* process.argv.
+ * @param {boolean} opt_ignoreUnrecognized Don't throw errors if unrecognized
+ * flags are encountered.
*/
-exports.parse = function(opt_args) {
+exports.parse = function(opt_args, opt_ignoreUnrecognized) {
var args = opt_args || process.argv.slice(2);
if (parseCalled) return;
@@ -200,7 +202,7 @@ exports.parse = function(opt_args) {
} catch (e) {
throwFlagParseError(args, i, e.message);
}
- } else {
+ } else if (!opt_ignoreUnrecognized) {
throwFlagParseError(args, i, 'Unrecognized flag name "' + arg + '"');
}

0 comments on commit 26dd3f0

Please sign in to comment.
Something went wrong with that request. Please try again.