Using and Mastering Cookiecutter Transcripts
Chapter: Advanced Cookiecutter usage
Lecture: Concept: Default values

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Here is a slightly richer default configuration file, for Cookiecutter.
0:06 So we've seen the default context, and these are the values
0:09 that get past to the actual templates to overwrite their defaults,
0:14 so we've added full name, email and GitHub username,
0:17 so we don't have to type that again, we can also set some directories, right,
0:22 so we can come down here and say if I don't want .cookiecutters
0:26 to be the folder where it does a checkout
0:28 and where it manages all my Cookiecutter data, well,
0:31 I can change cookiecutters_dir put that somewhere else.
0:34 Similarly, there is a replay directory that takes the inputs you give the template,
0:38 we'll talk about that later, but you can overwrite that directory as well.
0:41 You can also create little shortcuts, so if you want to
0:44 instead of type, you could just type bb:thatthing,
0:50 or even if you want just a shorter version, just ps,
0:53 so if I want to run Pyramid Cookiecutter starter often,
0:56 I could just say cookiecutter ps enter
0:59 and that would run that template over and over again.
1:02 You can see, we have the little {0} string format type things to fill in pieces,
1:06 so you can create really interesting little aliases here.
1:09 In order for you to avoid typing the config file name all the time,
1:14 just do set up an environment variable, COOKIECUTTER_CONFIG
1:18 and set its value to be wherever that file lives.
1:22 So on Linux or Mac OS you say export COOKIECUTTER_CONFIG=this
1:26 and you put that into your ~/.profile, your ~/.zshrc
1:29 wherever your shell startup script is.
1:33 So this sets the environment variable so Cookiecutter will always use it,
1:36 unless you specify --default-config and then it says
1:40 I know there is this environment variable set,
1:43 but just run the thing entirely from scratch, which is mostly used
1:46 for when you either want to see what their defaults would have been
1:49 or if you're developing your own templates
1:52 and you want to make sure the defaults work okay.
1:55 Now, how about on Windows, if we're going to do this on Windows,
1:57 you don't have like a ~/.profile file, instead, you have a GUI
2:01 for managing your environment variables, so open up the Control panel,
2:04 go to System and then click on Advanced system settings,
2:08 it will open up this dialogue, click on Environment Variables there,
2:11 it will open up this dialogue and then you can add a New User Variable.
2:17 So COOKIECUTTER_CONFIG and then you put the path
2:20 to wherever you happen to want it to be, right,
2:23 I put it in the .cookiecutters folder, you can put it wherever you like.
2:26 Now, just, it seemed odd to me, but for some reason,
2:29 I think actually I had to reboot Windows, at least log out, for it to take this value,
2:33 it seems like it was really not working, like restarting my terminal
2:36 or my command prompt was not enough,
2:38 I had to actually reboot Windows or log out,
2:40 so just be aware that you might have to
2:42 give this thing a strong kick to get it to take it,
2:45 maybe you will have better luck than me, I don't know.
2:47 Alright, so let's see these default values in action,
2:49 create that file and register the environment variable either in ~/.profile
2:52 or in Windows in the environment variables, we run it, we can say hit enter, go.
2:57 And now, you can see it's pulling all of our variables in,
3:00 and putting them as the default, so you can just hit enter, enter, enter,
3:03 and it will accept Michael Kennedy, michael@talkpython,fm, and so on.
3:07 That's much better.