UI for Zipcoin Blue

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