-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
placeholder
with no default
does not force the user to answer
#1753
Comments
Interactive prompting is a little tricky because for Let's assume the following str_1: ""
str_2:
default: ""
str_3:
type: str All three questions are (implicit or explicit) It's similar for yaml_1: null
yaml_2:
default: null
yaml_3:
type: yaml All three questions are (implicit or explicit) So, your discovery is in fact not related to the use of I don't see how we could change the current behavior, but I'm all ears if you have an idea. Your proposed workaround using a validator does not precisely catch an unanswered question but constrains the answer to not be falsy, which coincidentally means it must not be |
I've done some more testing, and I see what you are saying now. It works as I would expect for types other than I don't have a better idea other than adding a new supported key for advanced prompts such as I really liked the idea of Thanks |
I think the MVP would be to document this behavior, and how validators can be used for this use case, so it's not surprising to users. |
Describe the problem
According to the docs,
default
should be left empty to force the user to answer. However, even with nodefault
, ifplaceholder
is set then the user is not forced to answer the prompt.Template
To Reproduce
Run copier with the
copier.yml
from the previous section. When prompted forrequired_var
, simply hit enter.Example:
Logs
No response
Expected behavior
When prompted, the user should be forced to enter a value and not be able to just hit enter, which effectively sets the value to
None
,""
, etc. depending on the type.Screenshots/screencasts/logs
No response
Operating system
macOS
Operating system distribution and version
Sonoma 14.6.1
Copier version
copier 9.3.1
Python version
Python 3.12.4
Installation method
pip+pypi
Additional context
This behavior can be worked-around with something like this:
... but that is a lot of boilerplate to add.
The text was updated successfully, but these errors were encountered: