Search code examples
cookiecutter

Don't ask for a derived variable in cookiecutter


This is my cookiecutter.json file:

{
    "day": "1",
    "directory_name": "day-{{ cookiecutter.day }}"
}

Now I only want to be prompted for the day, but not for the directory_name which is derived from it. How do I get that to happen?

The documentation for no_input is less than helpful.


Solution

  • The no-input option is general option, allowing you to use all the defaults and skipping the questions overall.

    What you need is a private variable

    {
        "day": "1",
        "__directory_name": "day-{{ cookiecutter.day }}"
    }