Skip to content

Conversation

@AdamPiotrowski91
Copy link

This PR implements a base class which allows to customize prompt format when used directly via click.prompt or click.confirm methods.

It adds an optional parameter which can be an instance of a PromptBuilder class or one inheriting from it.

You can customize all of the below in any combination:

  • how the prompt is built via overriding build method
  • how the choices are shown via overriding add_choices method
  • how the default is shown via overriding add_default method
  • how to calculate if choices should be shown via overriding should_add_choices method
  • how to calculate if default should be shown via overriding should_add_default method

fixes #2875

- create PromptBuilder class in a raw form
- rework _build_prompt into instance of the above class
- all initial tests work, as expected - no backward incompatibilities
- add builder_cls parameters to promp generator functions
- docstrings & tests
@AdamPiotrowski91
Copy link
Author

Tests pass, but I am not sure, based on the logs, why do the other jobs fail. Would appreciate some help in this regard.

@Rowlando13 Rowlando13 marked this pull request as draft August 23, 2025 08:07
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 this pull request may close these issues.

Method used to build prompts under the hood does not allow for full format customization

1 participant