Using and Mastering Cookiecutter Transcripts
Chapter: Creating Cookiecutter templates
Lecture: Helper text via post-generation hooks
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
We've seen that we can use our post generation hook for deleting files, right,
0:06
we had a certain number of files here that we only wanted to keep some of them in the situation where we picked up particular color.
0:15
A real world example of this would be a web application with different types of templates, Jinja, Chameleon, Mako and so on,
0:21
and you only want to keep the files that correspond to the ones selected, by the creator, the person who ran the Cookiecutter template.
0:31
Now we're going to do one final thing here, we're going to display some helpful instructions for the user,
0:38
okay, so when we run the Cookiecutter template, what we'd love to see is here we've created your project,
0:44
we asked you the questions, and here is a friendly little getting started message so we can help people fall into the pit of success.
0:51
These are the next steps you should take, if you feel lost- don't, just do this.
0:55
So I've already pre created a little message here so I am just going to paste it in, so we need to somehow get the favorite color
1:02
because my message says welcome to the color project, and you choose this color, the world is a rainbow, but mostly,
1:09
it's this colored rainbow, okay, to get started read me, obviously you would have different types of messages here,
1:16
but let's say we have this method up top here, that already is getting the color let's move this getting the favorite color out, and passed around.
1:25
Like so. Down here, we can pass in this favorite color, there we go, it's not really a performance thing, this is actually just a static string,
1:38
it's pre replaced with the color when they selected it, but I kind of like having this ability to get in one place and pass it around.
1:46
Alright, so now we should have a nice message when we're done with this. Okay, let's create one final template, so again, it's going to be
1:54
cookiecutter cookiecutter_colors, we're going to run this here, and let's see, the project is going to be final exam
2:03
and of course our little dependent property here, grab that and create this, you creator is going to be me,
2:10
so I'll just put MK it's created on this day, when I recorded it, I am feeling yellow again and let's go, what is going to happen,
2:17
it's going to run our hook, it's going to remove the extra files, right, the blue and the green, and it's also going to give us that nice message,
2:26
let's see how that works Boom, welcome to the color project, yellow, the world is a rainbow, but mostly it's yellow,
2:34
so to get started, you can read the readme, how cool is that, this is a super sleek project creation experience.
2:41
I run the little thing and as we'll see later, you can actually run a custom script out of your project and it could call this API,
2:48
and all the stuff is happening, and then when we are done, we get this nice little message that we just added in our post generation hook.