expand.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- coding: utf-8 -*-
  2. """
  3. * example for expand question type
  4. * run example by typing `python example/checkbox.py` in your console
  5. """
  6. from __future__ import print_function, unicode_literals
  7. from PyInquirer import style_from_dict, Token, prompt, print_json, Separator
  8. from examples import custom_style_2
  9. # questions -
  10. questions = [
  11. {
  12. 'type': 'expand',
  13. 'message': 'Conflict on `file.js`: ',
  14. 'name': 'overwrite',
  15. 'default': 'a',
  16. 'choices': [
  17. {
  18. 'key': 'y',
  19. 'name': 'Overwrite',
  20. 'value': 'overwrite'
  21. },
  22. {
  23. 'key': 'a',
  24. 'name': 'Overwrite this one and all next',
  25. 'value': 'overwrite_all'
  26. },
  27. {
  28. 'key': 'd',
  29. 'name': 'Show diff',
  30. 'value': 'diff'
  31. },
  32. Separator(),
  33. {
  34. 'key': 'x',
  35. 'name': 'Abort',
  36. 'value': 'abort'
  37. }
  38. ]
  39. }
  40. ]
  41. answers = prompt(questions, style=custom_style_2)
  42. print(answers)