Using and Mastering Cookiecutter Transcripts
Chapter: Advanced Cookiecutter usage
Lecture: Instant replays

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Now sometimes when you're working, you want to replay exactly what you just entered, this is common if you're doing sort of template generation,
0:12 like if you're building a template for your own project, or maybe even from continuous integration, so let's go over here
0:17 and just look really quick at this, notice that it's the bottle, the cookiecutter for creating bottle, blah, blah, blah, right,
0:24 so this was passed to this template, right, the name of here and all sorts of stuff, my name and so on, so let's erase this, and do one more time,
0:33 we're going to create it just as before, but instead of doing any of this stuff, we're going to say --replay hit enter, and boom, done,
0:44 if we go back over here, we now have the Bottle, if we look at this, we can see "The Bottle" like that and we have the_bottle typed like this.
0:57 Those are exactly the values that we passed in, so what you can do is that you can run a template and it may have some interesting questions
1:04 it was going to ask you, and we can just say --replay and it's going to store that somewhere.
1:10 The question is where is this stored, well, if we look here, we now have two cookiecutters we have a ~/.cookiecutter and a ~/.cookiecutter_replay,
1:20 we look in there, there is a cookiecutter-bottle.json, alright, so let's just look and see what's in there.
1:27 And notice, we have cookiecutter full_name is Michael Kennedy, those three came from our defaults,
1:34 I mean, we entered them into the system, but those came from the defaults. This one and that one we passed on the command line
1:42 and this one was just the default out of the template and so it's stored with the final results set of all the values passed to the template
1:49 before it ran it, in this file, right, so you can on a per template type bases always do cookiecutter cookiecutter-the-thing --replay
1:59 and it's going to do that same this, so for example, on some sort of continuous integration thing,
2:05 you could run this once and then it will store this value or technically you could little adjust create this file,
2:11 and put it in the right place and then those values will be used regardless of what gets put in the template.
2:16 This is also super useful if you're developing your own template, you want to type in something under certain circumstances,
2:22 see what is generated, oh it didn't come out right, go make it edit, rerun it --replay make an edit, rerun it --replay you'll get the hang of it.


Talk Python's Mastodon Michael Kennedy's Mastodon