With --no--input, input validation is disabled and boolean unusable

Author: GutsCreated Nov 18, 2024Updated Sep 16, 2026

Description:

I'm trying to use boolean values in template option as documented here: https://cookiecutter.readthedocs.io/en/stable/advanced/boolean_variables.html#basic-usage.

Specifically:

  • input validation: is value a valid boolean, i.e. one of
  • it's possible to test value within template using jinja's syntax

I've just edited my template with the documentation option (see latest line):

json
{
  [...]
  "run_as_docker": true

}

What I've run:

Input validation is not working with --no-input option

bash
cookiecutter --no-input -f ~/Git/Oslandia/QGIS/template-qgis-plugin/ plugin_name=issue_processing_option run_as_docker=docker --verbose

I can passe anything to boolean option. I guess it's not a bug and using --no-input disable validation? If so, we should update the documentation (or well pointing me on where it's stipulated, I might missed something).

Boolean test does not work

Then let's say I've something like the following in my template files:

jinja
{{ cookiecutter.run_as_docker }} {{ cookiecutter.run_as_docker is boolean }}

{% if cookiecutter.run_as_docker %}

Containers ON.

{% else %}

No container.

{% endif %}

If I run:

bash
cookiecutter -f ~/Git/Oslandia/QGIS/template-qgis-plugin/ plugin_name=issue_processing_option

Answering y or n, I've the correct result.

But if I run with --no--input, it does not work:

bash
cookiecutter -f ~/Git/Oslandia/QGIS/template-qgis-plugin/ plugin_name=issue_processing_option run_as_docker=true --no-input
# or
cookiecutter -f ~/Git/Oslandia/QGIS/template-qgis-plugin/ plugin_name=issue_processing_option run_as_docker=false --no-input

run_as_docker is a string and {% if cookiecutter.run_as_docker %} always True:

false False



Containers ON.

So --no-input is not compatible with input types other than string?

Source: cookiecutter/cookiecutter