Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
antazoey opened this issue Oct 4, 2023 · 0 comments · May be fixed by #2622
Open

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

antazoey opened this issue Oct 4, 2023 · 0 comments · May be fixed by #2622

Comments

@antazoey
Copy link
Contributor

antazoey commented Oct 4, 2023

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.

@antazoey antazoey linked a pull request Oct 4, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant