source: frontend/node_modules/argparse/lib/action/store.js

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

Fix frontend appearance

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*:nodoc:*
2 * class ActionStore
3 *
4 * This action just stores the argument’s value. This is the default action.
5 *
6 * This class inherited from [[Action]]
7 *
8 **/
9'use strict';
10
11var util = require('util');
12
13var Action = require('../action');
14
15// Constants
16var c = require('../const');
17
18
19/*:nodoc:*
20 * new ActionStore(options)
21 * - options (object): options hash see [[Action.new]]
22 *
23 **/
24var ActionStore = module.exports = function ActionStore(options) {
25 options = options || {};
26 if (this.nargs <= 0) {
27 throw new Error('nargs for store actions must be > 0; if you ' +
28 'have nothing to store, actions such as store ' +
29 'true or store const may be more appropriate');
30
31 }
32 if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
33 throw new Error('nargs must be OPTIONAL to supply const');
34 }
35 Action.call(this, options);
36};
37util.inherits(ActionStore, Action);
38
39/*:nodoc:*
40 * ActionStore#call(parser, namespace, values, optionString) -> Void
41 * - parser (ArgumentParser): current parser
42 * - namespace (Namespace): namespace for output data
43 * - values (Array): parsed values
44 * - optionString (Array): input option string(not parsed)
45 *
46 * Call the action. Save result in namespace object
47 **/
48ActionStore.prototype.call = function (parser, namespace, values) {
49 namespace.set(this.dest, values);
50};
Note: See TracBrowser for help on using the repository browser.