source: frontend/node_modules/argparse/lib/argument/exclusive.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[9af201e]1/** internal
2 * class MutuallyExclusiveGroup
3 *
4 * Group arguments.
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
10 *
11 * This class inherited from [[ArgumentContainer]]
12 **/
13'use strict';
14
15var util = require('util');
16
17var ArgumentGroup = require('./group');
18
19/**
20 * new MutuallyExclusiveGroup(container, options)
21 * - container (object): main container
22 * - options (object): options.required -> true/false
23 *
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)
26 **/
27var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {
28 var required;
29 options = options || {};
30 required = options.required || false;
31 ArgumentGroup.call(this, container);
32 this.required = required;
33
34};
35util.inherits(MutuallyExclusiveGroup, ArgumentGroup);
36
37
38MutuallyExclusiveGroup.prototype._addAction = function (action) {
39 var msg;
40 if (action.required) {
41 msg = 'mutually exclusive arguments must be optional';
42 throw new Error(msg);
43 }
44 action = this._container._addAction(action);
45 this._groupActions.push(action);
46 return action;
47};
48
49
50MutuallyExclusiveGroup.prototype._removeAction = function (action) {
51 this._container._removeAction(action);
52 this._groupActions.remove(action);
53};
54
Note: See TracBrowser for help on using the repository browser.