Using and Mastering Cookiecutter Transcripts
Chapter: Programmatic Cookiecutter: Using the API
Lecture: Why the API?

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Cookiecutter is a very powerful in its own right. We've seen the pre and post generation hooks,
0:07 the dependent properties in the cookiecutter.json, and so on, so there is quite a bit we can do just within Cookiecutter itself,
0:13 but, there are many times we want more control over this, or we wanted to feel more native or we don't want to tell people
0:20 hey you have to use Cookiecutter, just say use our application, run this command and you'll get started,
0:25 but we of course don't want to do all that file management, projects, text juggling that Cookicutter does for us.
0:31 So, we can wrap the Cookicutter API in our own application, be that Python, .Net, Java whatever, and we can use that
0:40 to interact with the user, but actually use the Cookicutter API just like you've seen all the features we've seen creating the templates,
0:48 we can use that from the API to create our project in the end. So, I'll give you two quick examples,
0:54 if I want to get a new project started in Pyramid, the web framework in Python, there is a whole bunch of stuff
1:00 I've got to do really to get started, I've got to create the templates, I've got to create the views and maybe even I want testing,
1:06 it's a Python package, so it's got to have a certain amount or structure put together
1:09 so that it represents that, there is a lot of things to do to get started. And sort of just telling you to do that, they say
1:17 hey you can just run this command pcreate -s (for scaffold) starter and the name of your app, and we'll go and create that for you,
1:24 so then you can just run it and have a working app to start from, that's great; it turns out pcreate actually wraps the cookicutter API
1:32 and calls the started Cookicutter template from Pyramid to do that, which is really cool. You run this command, it asks you a few questions,
1:40 probably looks familiar, it doesn't have to though, because, you can ask these questions in your app
1:46 and just feed the answers directly to Cookiecutter. Another example might be django-admin, maybe we want to create a new project called my site,
1:54 something like this, I don't think django-admin uses cookicutter, it may, but it's just another example of here is some part of my app,
2:01 it helps you get started by generating a project that could easily be a Cookicutter template.
2:06 Right, off it goes, it does whatever it does to create your project, ideally that's with Cookicutter.

Talk Python's Mastodon Michael Kennedy's Mastodon