react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / lib / action / append.js
80728 views/*:nodoc:*1* class ActionAppend2*3* This action stores a list, and appends each argument value to the list.4* This is useful to allow an option to be specified multiple times.5* This class inherided from [[Action]]6*7**/89'use strict';1011var util = require('util');1213var Action = require('../action');1415// Constants16var $$ = require('../const');1718/*:nodoc:*19* new ActionAppend(options)20* - options (object): options hash see [[Action.new]]21*22* Note: options.nargs should be optional for constants23* and more then zero for other24**/25var ActionAppend = module.exports = function ActionAppend(options) {26options = options || {};27if (this.nargs <= 0) {28throw new Error('nargs for append actions must be > 0; if arg ' +29'strings are not supplying the value to append, ' +30'the append const action may be more appropriate');31}32if (!!this.constant && this.nargs !== $$.OPTIONAL) {33throw new Error('nargs must be OPTIONAL to supply const');34}35Action.call(this, options);36};37util.inherits(ActionAppend, Action);3839/*:nodoc:*40* ActionAppend#call(parser, namespace, values, optionString) -> Void41* - parser (ArgumentParser): current parser42* - namespace (Namespace): namespace for output data43* - values (Array): parsed values44* - optionString (Array): input option string(not parsed)45*46* Call the action. Save result in namespace object47**/48ActionAppend.prototype.call = function (parser, namespace, values) {49var items = [].concat(namespace[this.dest] || []); // or _.clone50items.push(values);51namespace.set(this.dest, items);52};5354555657