charmbracelet / gum

A tool for glamorous shell scripts 🎀
MIT License
17.94k stars 339 forks source link

Multiple choices for gum confirm #670

Open vt-alt opened 3 weeks ago

vt-alt commented 3 weeks ago

Is your feature request related to a problem? Please describe. For example I want user not just say yes no but to have additional choice, for example cancel or view details. Triple choice is quite frequent in cli dialogs.

Describe the solution you'd like Would be good if gum supports multiple choices for gum confirm. To behave similar to gum choose but with horizontal selection menu.

Perhaps it should return exit code with selection number. For example for Yes/No it will be backward compatible 0/1, but for Yes/Details/No it will be 0/1/2 so that No still return non-zero exit code., which is backward compatible again.

Describe alternatives you've considered There is gum choose but it have a different UI/UX purpose. (And returns different values).

Additional context Alternatively, this can be an option to gum choose to display option horizontally and return selection text. That way gum choose --horizontal Yes No would simulate gum confirm somehow. But this will require parsing text (and this can introduce mistakes when text is edited but its parser not). Maybe in that case gum choose could have extension to options format, like gum select --horizontal 0=Yes 1=No 4=Cancel and if user selects "Cancel" it will print string "4" instead of "Cancel".