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.

inquirer.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict';
  2. /**
  3. * Inquirer.js
  4. * A collection of common interactive command line user interfaces.
  5. */
  6. var inquirer = module.exports;
  7. /**
  8. * Client interfaces
  9. */
  10. inquirer.prompts = {};
  11. inquirer.Separator = require('./objects/separator');
  12. inquirer.ui = {
  13. BottomBar: require('./ui/bottom-bar'),
  14. Prompt: require('./ui/prompt')
  15. };
  16. /**
  17. * Create a new self-contained prompt module.
  18. */
  19. inquirer.createPromptModule = function(opt) {
  20. var promptModule = function(questions) {
  21. var ui = new inquirer.ui.Prompt(promptModule.prompts, opt);
  22. var promise = ui.run(questions);
  23. // Monkey patch the UI on the promise object so
  24. // that it remains publicly accessible.
  25. promise.ui = ui;
  26. return promise;
  27. };
  28. promptModule.prompts = {};
  29. /**
  30. * Register a prompt type
  31. * @param {String} name Prompt type name
  32. * @param {Function} prompt Prompt constructor
  33. * @return {inquirer}
  34. */
  35. promptModule.registerPrompt = function(name, prompt) {
  36. promptModule.prompts[name] = prompt;
  37. return this;
  38. };
  39. /**
  40. * Register the defaults provider prompts
  41. */
  42. promptModule.restoreDefaultPrompts = function() {
  43. this.registerPrompt('list', require('./prompts/list'));
  44. this.registerPrompt('input', require('./prompts/input'));
  45. this.registerPrompt('number', require('./prompts/number'));
  46. this.registerPrompt('confirm', require('./prompts/confirm'));
  47. this.registerPrompt('rawlist', require('./prompts/rawlist'));
  48. this.registerPrompt('expand', require('./prompts/expand'));
  49. this.registerPrompt('checkbox', require('./prompts/checkbox'));
  50. this.registerPrompt('password', require('./prompts/password'));
  51. this.registerPrompt('editor', require('./prompts/editor'));
  52. };
  53. promptModule.restoreDefaultPrompts();
  54. return promptModule;
  55. };
  56. /**
  57. * Public CLI helper interface
  58. * @param {Array|Object|Rx.Observable} questions - Questions settings array
  59. * @param {Function} cb - Callback being passed the user answers
  60. * @return {inquirer.ui.Prompt}
  61. */
  62. inquirer.prompt = inquirer.createPromptModule();
  63. // Expose helper functions on the top level for easiest usage by common users
  64. inquirer.registerPrompt = function(name, prompt) {
  65. inquirer.prompt.registerPrompt(name, prompt);
  66. };
  67. inquirer.restoreDefaultPrompts = function() {
  68. inquirer.prompt.restoreDefaultPrompts();
  69. };