2 * class MutuallyExclusiveGroup
5 * By default, ArgumentParser groups command-line arguments
6 * into “positional arguments” and “optional arguments”
7 * when displaying help messages. When there is a better
8 * conceptual grouping of arguments than this default one,
9 * appropriate groups can be created using the addArgumentGroup() method
11 * This class inherited from [[ArgumentContainer]]
15 var util = require('util');
17 var ArgumentGroup = require('./group');
20 * new MutuallyExclusiveGroup(container, options)
21 * - container (object): main container
22 * - options (object): options.required -> true/false
24 * `required` could be an argument itself, but making it a property of
25 * the options argument is more consistent with the JS adaptation of the Python)
27 var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {
29 options = options || {};
30 required = options.required || false;
31 ArgumentGroup.call(this, container);
32 this.required = required;
35 util.inherits(MutuallyExclusiveGroup, ArgumentGroup);
38 MutuallyExclusiveGroup.prototype._addAction = function (action) {
40 if (action.required) {
41 msg = 'mutually exclusive arguments must be optional';
44 action = this._container._addAction(action);
45 this._groupActions.push(action);
50 MutuallyExclusiveGroup.prototype._removeAction = function (action) {
51 this._container._removeAction(action);
52 this._groupActions.remove(action);