react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / lib / argument / exclusive.js
80728 views/** internal1* class MutuallyExclusiveGroup2*3* Group arguments.4* By default, ArgumentParser groups command-line arguments5* into “positional arguments” and “optional arguments”6* when displaying help messages. When there is a better7* conceptual grouping of arguments than this default one,8* appropriate groups can be created using the addArgumentGroup() method9*10* This class inherited from [[ArgumentContainer]]11**/12'use strict';1314var util = require('util');1516var ArgumentGroup = require('./group');1718/**19* new MutuallyExclusiveGroup(container, options)20* - container (object): main container21* - options (object): options.required -> true/false22*23* `required` could be an argument itself, but making it a property of24* the options argument is more consistent with the JS adaptation of the Python)25**/26var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {27var required;28options = options || {};29required = options.required || false;30ArgumentGroup.call(this, container);31this.required = required;3233};34util.inherits(MutuallyExclusiveGroup, ArgumentGroup);353637MutuallyExclusiveGroup.prototype._addAction = function (action) {38var msg;39if (action.required) {40msg = 'mutually exclusive arguments must be optional';41throw new Error(msg);42}43action = this._container._addAction(action);44this._groupActions.push(action);45return action;46};474849MutuallyExclusiveGroup.prototype._removeAction = function (action) {50this._container._removeAction(action);51this._groupActions.remove(action);52};53545556