I need this exact opportunity just a few days ago. The solution I came up with was to write a wrapper script for cookiecutter, similar to what is stated in:
http://cookiecutter.readthedocs.io/en/latest/advanced_usage.html#calling-cookiecutter-functions-from-python
My script creates a random string for use in a Django project. I called the shorthand script:
#! /usr/bin/env python from cookiecutter.main import cookiecutter import os rstring = ''.join([c for c in os.urandom(1024) if c.isalnum()])[:64] cookiecutter( 'django-template',
So now I just run cut-cut and execute the process as usual. The only difference is that the entry with the name secret in my cookiecutter.json file is pre-populated with the generated value in rstring from the script provided through the passed extra_context.
You can modify the script to accept the template via the command line, but in my use I always use the same template, so I just pass in the hard-coded value of "django-template" as indicated in the code above.
source share