petereon / beaupy

A Python library of interactive CLI elements you have been looking for
https://petereon.github.io/beaupy/
MIT License
181 stars 13 forks source link

Sectioned `select` and `select_multiple` #74

Open petereon opened 9 months ago

petereon commented 9 months ago

select and select_multiple should be able to section the options in the multiple sections. To provide sections Dict[str, List[str]] would be passed as an options argument, such that the keys are section names and values are lists of options to be presented in that section. This bring into the questions of how the preprocessing of the options will work having passed a Dict rather than a List.

yfernandes-uturn commented 9 months ago

Hello! I recently started using beaupy and felt the need for a title for both select and select_multiple. The documentation suggests using a regular print, but for an application with different data inputs, it looked odd since the prompts would display questions that disappeared once the user confirmed their answer, but the selects didn’t. I went ahead and created a fork and implemented this. I know it's not quite the same idea as this issue, but if you find it useful, I can open a PR. Here's the comparison link: https://github.com/petereon/beaupy/compare/master...yfernandes-uturn:beaupy:feature/title-for-selects

petereon commented 9 months ago

This definitely sounds useful and is a very welcome change, please feel free to open a PR.

petereon commented 9 months ago

@yfernandes-uturn Including a comment on another PR related to this feature as a reference: https://github.com/petereon/beaupy/pull/72#issuecomment-1721176046

Feel free to diverge from whatever I have described there, but please don't rely on specific string formatting (as in #72) or some sort of numeric indexing (as cutie) as such things lack transparency for the user.