4 * This action just stores the argument’s value. This is the default action.
6 * This class inherited from [[Action]]
11 var util = require('util');
13 var Action = require('../action');
16 var c = require('../const');
20 * new ActionStore(options)
21 * - options (object): options hash see [[Action.new]]
24 var 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');
32 if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
33 throw new Error('nargs must be OPTIONAL to supply const');
35 Action.call(this, options);
37 util.inherits(ActionStore, Action);
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)
46 * Call the action. Save result in namespace object
48 ActionStore.prototype.call = function (parser, namespace, values) {
49 namespace.set(this.dest, values);