项目原始demo,不改动
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.
 
 
 
 

41 lignes
1.0 KiB

  1. /*:nodoc:*
  2. * class ActionCount
  3. *
  4. * This counts the number of times a keyword argument occurs.
  5. * For example, this is useful for increasing verbosity levels
  6. *
  7. * This class inherided from [[Action]]
  8. *
  9. **/
  10. 'use strict';
  11. var util = require('util');
  12. var Action = require('../action');
  13. /*:nodoc:*
  14. * new ActionCount(options)
  15. * - options (object): options hash see [[Action.new]]
  16. *
  17. **/
  18. var ActionCount = module.exports = function ActionCount(options) {
  19. options = options || {};
  20. options.nargs = 0;
  21. Action.call(this, options);
  22. };
  23. util.inherits(ActionCount, Action);
  24. /*:nodoc:*
  25. * ActionCount#call(parser, namespace, values, optionString) -> Void
  26. * - parser (ArgumentParser): current parser
  27. * - namespace (Namespace): namespace for output data
  28. * - values (Array): parsed values
  29. * - optionString (Array): input option string(not parsed)
  30. *
  31. * Call the action. Save result in namespace object
  32. **/
  33. ActionCount.prototype.call = function (parser, namespace) {
  34. namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
  35. };