Back to Cookiecutter

Replay Project Generation

docs/advanced/replay.rst

2.7.11.7 KB
Original Source

.. _replay-feature:

Replay Project Generation

New in Cookiecutter 1.1

On invocation Cookiecutter dumps a json file to ~/.cookiecutter_replay/ which enables you to replay later on.

In other words, it persists your input for a template and fetches it when you run the same template again.

Example for a replay file (which was created via cookiecutter gh:hackebrot/cookiedozer):

.. code-block:: JSON

{
    "cookiecutter": {
        "app_class_name": "FooBarApp",
        "app_title": "Foo Bar",
        "email": "[email protected]",
        "full_name": "Raphael Pierzina",
        "github_username": "hackebrot",
        "kivy_version": "1.8.0",
        "project_slug": "foobar",
        "short_description": "A sleek slideshow app that supports swipe gestures.",
        "version": "0.1.0",
        "year": "2015"
    }
}

To fetch this context data without being prompted on the command line you can use either of the following methods.

Pass the according option on the CLI:

.. code-block:: bash

cookiecutter --replay gh:hackebrot/cookiedozer

Or use the Python API:

.. code-block:: python

from cookiecutter.main import cookiecutter
cookiecutter('gh:hackebrot/cookiedozer', replay=True)

This feature comes in handy if, for instance, you want to create a new project from an updated template.

Custom replay file


*New in Cookiecutter 2.0*

To specify a custom filename, you can use the ``--replay-file`` option:

.. code-block:: bash

    cookiecutter --replay-file ./cookiedozer.json gh:hackebrot/cookiedozer

This may be useful to run the same replay file over several machines, in tests or when a user of the template reports a problem.