Keine Beschreibung

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*:nodoc:*
  2. * class ActionHelp
  3. *
  4. * Support action for printing help
  5. * This class inherided from [[Action]]
  6. **/
  7. 'use strict';
  8. var util = require('util');
  9. var Action = require('../action');
  10. // Constants
  11. var $$ = require('../const');
  12. /*:nodoc:*
  13. * new ActionHelp(options)
  14. * - options (object): options hash see [[Action.new]]
  15. *
  16. **/
  17. var ActionHelp = module.exports = function ActionHelp(options) {
  18. options = options || {};
  19. if (options.defaultValue !== null) {
  20. options.defaultValue = options.defaultValue;
  21. }
  22. else {
  23. options.defaultValue = $$.SUPPRESS;
  24. }
  25. options.dest = (options.dest !== null ? options.dest: $$.SUPPRESS);
  26. options.nargs = 0;
  27. Action.call(this, options);
  28. };
  29. util.inherits(ActionHelp, Action);
  30. /*:nodoc:*
  31. * ActionHelp#call(parser, namespace, values, optionString)
  32. * - parser (ArgumentParser): current parser
  33. * - namespace (Namespace): namespace for output data
  34. * - values (Array): parsed values
  35. * - optionString (Array): input option string(not parsed)
  36. *
  37. * Print help and exit
  38. **/
  39. ActionHelp.prototype.call = function (parser) {
  40. parser.printHelp();
  41. parser.exit();
  42. };