AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 351 forks source link

Support for custom select/mulitselect question template #392

Closed sihamais closed 2 years ago

sihamais commented 2 years ago

Hi,

I would like to know if there is a way to achieve this kind of template for the select/mulitselect prompt

? [question] : [help]
> [option1]     [description1]
  [option2]     [description2]

without having to transform it's result to extract the option?

mislav commented 2 years ago

Hi, this cannot be done without transforming the result. You can do the following:

  1. Have the original slice of option1, option2, etc.
  2. Make a new slice of options with descriptions,
  3. Use the new slice with select/multiselect, but assign the result to an int variable,
  4. Look up the result in the original slice using the int index.