pallets / click

Python composable command line interface toolkit

Home Page:https://click.palletsprojects.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow customizing fail message for invalid choice in `click.types.Choice`

antazoey opened this issue · comments

Move the fail art of convert() in the Choice class to a new method get_invalid_choice_fail_message(self) so in my subclass of click.Choice I can customize the way it shows the failing value for the choice

Some CLI option choices are multi-part meaning they are separated by some value, like a comma separated list for example. Maybe each section of this value represents a different part of a schema and it is nice to show a custom message about the specific part.

Contrived version:
Let says my choices are ["maine::goat", "maine::themepark"] and I give it "maine::toast", it'd be nice to say the mainepart was correct and thetoast` part was not.