source: frontend/node_modules/argparse/lib/action/append.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.5 KB
Line 
1/*:nodoc:*
2 * class ActionAppend
3 *
4 * This action stores a list, and appends each argument value to the list.
5 * This is useful to allow an option to be specified multiple times.
6 * This class inherided from [[Action]]
7 *
8 **/
9
10'use strict';
11
12var util = require('util');
13
14var Action = require('../action');
15
16// Constants
17var c = require('../const');
18
19/*:nodoc:*
20 * new ActionAppend(options)
21 * - options (object): options hash see [[Action.new]]
22 *
23 * Note: options.nargs should be optional for constants
24 * and more then zero for other
25 **/
26var ActionAppend = module.exports = function ActionAppend(options) {
27 options = options || {};
28 if (this.nargs <= 0) {
29 throw new Error('nargs for append actions must be > 0; if arg ' +
30 'strings are not supplying the value to append, ' +
31 'the append const action may be more appropriate');
32 }
33 if (!!this.constant && this.nargs !== c.OPTIONAL) {
34 throw new Error('nargs must be OPTIONAL to supply const');
35 }
36 Action.call(this, options);
37};
38util.inherits(ActionAppend, Action);
39
40/*:nodoc:*
41 * ActionAppend#call(parser, namespace, values, optionString) -> Void
42 * - parser (ArgumentParser): current parser
43 * - namespace (Namespace): namespace for output data
44 * - values (Array): parsed values
45 * - optionString (Array): input option string(not parsed)
46 *
47 * Call the action. Save result in namespace object
48 **/
49ActionAppend.prototype.call = function (parser, namespace, values) {
50 var items = (namespace[this.dest] || []).slice();
51 items.push(values);
52 namespace.set(this.dest, items);
53};
Note: See TracBrowser for help on using the repository browser.