input_dropdown.adoc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. [#arg-dropdowns]
  2. = Input: Dropdowns
  3. Predefined choices are normally the safest type of arguments, because users are limited to only enter values that you specify.
  4. [source,yaml]
  5. ----
  6. actions:
  7. - title: Print a message
  8. icon: smile
  9. shell: echo "{{ message }}"
  10. arguments:
  11. - name: message
  12. description: The message you want to print out.
  13. choices:
  14. - title: Hello
  15. value: Hello there!
  16. - title: Goodbye
  17. value: Aww, goodbye. :-(
  18. ----
  19. Note that when predefined choices are used, the argument type is ignored.
  20. This is what it looks like in the web interface;
  21. image::args/dropdown/dropdown.png[]
  22. Then finally, when you execute this command, it would look something like this (remember that this is just a basic "echo" command).
  23. image::args/dropdown/dropdown-logs-list.png[]
  24. In the logs, you can then click on the log entry link to open the results;
  25. image::args/dropdown/dropdown-logs-detail.png[]
  26. [#args-dropdown-entities]
  27. == Using Entities in Dropdowns
  28. Dropdowns can also be populated with a list of entities, like this;
  29. [source,yaml]
  30. .`config.yaml`
  31. ----
  32. actions:
  33. - title: restart container
  34. shell: 'docker restart {{ containerToRestart }}'
  35. arguments:
  36. - name: containerToRestart
  37. entity: container
  38. title: 'Select Container'
  39. choices:
  40. - value: '{{ container.Names }}'
  41. title: '{{ container.Names }}'
  42. entities:
  43. - file: entities/containers.json
  44. name: container
  45. ----
  46. This is what it looks like in the web interface;
  47. image::args/dropdown/dropdown-entities.png[]
  48. IMPORTANT: Arguments with `entity` must define **exactly one** choice template. Multiple static choices combined with `entity` is invalid configuration and is rejected on startup.
  49. include::partial$args/reject-null.adoc[]
  50. == Default values
  51. Dropdown arguments can also have default values. This is done by adding a `default` key to the argument definition.
  52. include::partial$config-start.adoc[]
  53. ----
  54. actions:
  55. - title: "Print your favorite movie"
  56. shell: echo '{{ movie }} is amazing'
  57. arguments:
  58. - name: movie
  59. choices:
  60. - value: "Star Wars"
  61. - value: "Star Trek"
  62. - value: "The Matrix"
  63. default: "Star Trek"
  64. ----