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.

version.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*:nodoc:*
  2. * class ActionVersion
  3. *
  4. * Support action for printing program version
  5. * This class inherited from [[Action]]
  6. **/
  7. 'use strict';
  8. var util = require('util');
  9. var Action = require('../action');
  10. //
  11. // Constants
  12. //
  13. var c = require('../const');
  14. /*:nodoc:*
  15. * new ActionVersion(options)
  16. * - options (object): options hash see [[Action.new]]
  17. *
  18. **/
  19. var ActionVersion = module.exports = function ActionVersion(options) {
  20. options = options || {};
  21. options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
  22. options.dest = (options.dest || c.SUPPRESS);
  23. options.nargs = 0;
  24. this.version = options.version;
  25. Action.call(this, options);
  26. };
  27. util.inherits(ActionVersion, Action);
  28. /*:nodoc:*
  29. * ActionVersion#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. * Print version and exit
  36. **/
  37. ActionVersion.prototype.call = function (parser) {
  38. var version = this.version || parser.version;
  39. var formatter = parser._getFormatter();
  40. formatter.addText(version);
  41. parser.exit(0, formatter.formatHelp());
  42. };