Using and Mastering Cookiecutter Transcripts
Chapter: Getting started using Cookiecutter
Lecture: Concept: Running a template
Login or purchase this course to watch this video and the rest of the course contents.
0:01 We just ran the cookiecutter-bottle template. Let's look inside and see what happened.
0:08 From the outside, we typed in cookiecutter and we gave it the git repo,
0:11 it ask us a bunch of questions, we could either take the defaults or just hit enter,
0:15 and then, we had a project ready to go, all we had to do is cd into, whatever we called our project, install the requirements and run the server,
0:23 just like that, we had our web application running bottle, we didn't have to go and create all the files and set up the configs
0:29 or anything like that, so you saw we can use cookiecutter-bottle to get started really quickly with a bottle web app. So, let's look behind the scenes.
0:37 When we ran the command, cookiecutter (space) git repo, it ask for some inputs, it took those inputs either the defaults or the ones we provided
0:44 and it applied those somehow to our app, first thing that happens, git clone. So, cookiecutter is going to do a git clone of that repo
0:53 into our local .cookiecutter's hidden directory now this is hidden on a Mac or on Linux,
0:59 on Windows it's still called .cookiecutters but the . (dot) doesn't mean hidden in Windows so it just shows up in your user profile,
1:05 I guess that's probably unfortunate but it's not a big deal. now you can see if we say ls we've got
1:10 cookiecutter bottle, cookiecutter template and one for Pyramid, and once those are here we no longer have to use the remote address
1:16 we can just get them from here. If we happen to pass in a local template, not one on the network,
1:20 but just one on our file system, it wouldn't copy it here, it would just run it out of that location.
1:25 And you see once I go into the cookiecutter-bottle, my prompt changed to something recognizing it as git,
1:32 why- because as you saw, this is github repository, it just literally cloned it, we have all the branches and everything.
1:39 If we do this on Windows, it's very similar, but we just have a .cookiecutters folder, right, but other than that, this is basically the same thing.
1:47 So, regardless of the operating system you have, you're going to take this directory, you're going to feed it over to the cookiecutter engine;
1:54 the cookiecutter engine is going to look at a lot of things, most importantly, cookiecutter.json and it's going to take our inputs,
1:59 really that's where the prompts come from and then take the inputs from that results,
2:02 feed it here and then take the directory structure plus our inputs and generate our project skeleton.
2:08 And then, you're done, you're done using cookiecutter you can go now and work with your project and run it however you want.
2:14 If it's a Python project you can go run it with Python if it's a C++ project,
2:17 you open it up and compile it, whatever you want to do, it's now ready to roll. We also saw that once we've installed the template because it copies it
2:26 and it clones it into that .cookiecutter's directory, we can just run it with the short name,
2:31 so if we say cookiecutter cookiecutter-bottle it's just going to look in .cookiecutters for that project and either it will find it and run it,
2:37 or it will just say I have no idea what this is. Right, but because we already ran it here, everything works like a charm.