Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

constant.js 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*:nodoc:*
  2. * class ActionStoreConstant
  3. *
  4. * This action stores the value specified by the const keyword argument.
  5. * (Note that the const keyword argument defaults to the rather unhelpful null.)
  6. * The 'store_const' action is most commonly used with optional
  7. * arguments that specify some sort of flag.
  8. *
  9. * This class inherited from [[Action]]
  10. **/
  11. 'use strict';
  12. var util = require('util');
  13. var Action = require('../../action');
  14. /*:nodoc:*
  15. * new ActionStoreConstant(options)
  16. * - options (object): options hash see [[Action.new]]
  17. *
  18. **/
  19. var ActionStoreConstant = module.exports = function ActionStoreConstant(options) {
  20. options = options || {};
  21. options.nargs = 0;
  22. if (typeof options.constant === 'undefined') {
  23. throw new Error('constant option is required for storeAction');
  24. }
  25. Action.call(this, options);
  26. };
  27. util.inherits(ActionStoreConstant, Action);
  28. /*:nodoc:*
  29. * ActionStoreConstant#call(parser, namespace, values, optionString) -> Void
  30. * - parser (ArgumentParser): current parser
  31. * - namespace (Namespace): namespace for output data
  32. * - values (Array): parsed values
  33. * - optionString (Array): input option string(not parsed)
  34. *
  35. * Call the action. Save result in namespace object
  36. **/
  37. ActionStoreConstant.prototype.call = function (parser, namespace) {
  38. namespace.set(this.dest, this.constant);
  39. };