sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
950 stars 405 forks source link

Improve API for `ChoiceAttribute.configure()` #2465

Open dgw opened 1 year ago

dgw commented 1 year ago

Requested Feature

BooleanAttribute comes with a helpful override for the configure() method that automatically takes care of showing (Y/n) or (y/N) as appropriate after the prompt:

https://github.com/sopel-irc/sopel/blob/9a5e84d9578710cda07e815a417102a92fcf3412/sopel/config/types.py#L363

ChoiceAttribute should do something similar for its choices and include the list of options automatically, rather than making plugin authors manually insert the list of options into the prompt themselves.

Problems Solved

Plugin authors won't have to worry any more about whether they remembered to update the prompt choices (or code to generate them) after modifying the available values in a ChoiceAttribute.

Alternatives

No response

Notes

If implemented, needs to be planned and communicated ahead of time for a major release, probably 9.0. Changes to the prompt handling will definitely not play well across versions, unless plugin authors are OK with older versions of Sopel no longer showing the available choices in the prompt text.