Using and Mastering Cookiecutter Transcripts
Chapter: Advanced Cookiecutter usage
Lecture: The full CLI

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's look at the full command line interface.
0:05 We're going to dig into Cookiecutter's extra features
0:08 and we'll look at how each one of them works
0:10 and how you can get the most out of them.
0:12 Let's just start with a quick overview, so cookiecutter --help
0:15 and it's going to say here is the usage, right,
0:18 we're going to create some kind of project as you know,
0:20 first thing, you can say V or lower case --version to get the version,
0:24 that's easy you can say --no-input, now --no-input is really interesting,
0:29 each prompt that you see in that process that runs the template has a default,
0:34 so if you say --no-input it will ask no questions and just take all the defaults.
0:39 The place that to me seems most useful is if you want to execute
0:44 a Cookiecutter template as part of a continuous integration,
0:47 so you can just configure your CI build to run
0:51 with whatever the defaults are, and just say --no-input
0:54 and it will just run and output the results and then maybe do unittests
0:58 or builds or whatever you're going to do against the result of running that template.
1:02 You can say -c or --checkout to get alternate branches,
1:06 we've seen that we can run directly from GitHub repos or git repos in general,
1:11 and often, there is multiple branches, maybe we want to run
1:14 a different branch for whatever reason,
1:17 like we could be evolving our template and using the git flow
1:20 so we have a feature branch for some change, right,
1:22 we can run that by saying -c branch name along with the url.
1:26 So that's pretty cool.
1:29 Verbose, if you want to understand what Cookiecutter is doing,
1:32 -v is great because it will show you all the things,
1:35 especially this is really helpful when you are building your own template
1:38 or working with your own sort of post processing code that will run across this,
1:43 right, we have something called hooks that we'll look at later;
1:46 another thing you might want to do is enter some answer,
1:49 some specific value that says you're on this template
1:52 but you want to do it over and over again, right,
1:55 again, this is most helpful when you're doing some sort of template building,
1:58 right, I want to answer the questions this way and then see what happened,
2:02 delete, run it again, so you can say --replay and if you've run the template before,
2:06 it will just feed all the same answers, defaults or custom answers,
2:11 whatever you put into the answers for those prompts
2:14 and then reexecute it, so this is really nice.
2:17 Also, this could be useful for continuous integration as well.
2:20 -f again, if you want to blast away the files,
2:23 you want to be really careful here,
2:25 if you're just a regular user, and you are just running this,
2:28 this will erase whatever is there if there is a directory with the same name,
2:31 so don't blow away your project, but if you know what you're doing,
2:34 if you're building a template or you're doing continuous integration,
2:36 that might be exactly what you want, so a little -f it will save a lot of trouble.
2:41 You want to change where the files go, -o or --output-dir
2:45 Cookiecutter by default puts the generated project
2:48 as a subdirectory right wherever you are,
2:51 your working directory so this will let you overwrite that.
2:53 You can specify a configurations file, so if you run a lot of Cookiecuter templates
2:57 you are going to get tired of answering the question what is your name,
3:01 what is your email, what is your GitHub account name, things like that,
3:04 so we can create this thing called a config file, put my email address is this,
3:08 my GitHub account name is this, and then when Cookiecutter runs
3:13 it will look at this config file, if you pass it like this,
3:15 and it will change those default prompts to be your default values,
3:19 not the default values out of the template, that is so nice.
3:23 You can also say don't do that, don't run the configuration file,
3:27 run without it, you might be thinking well,
3:30 if you're going to just put --config-file it will run it, but just omit that,
3:35 well, we'll see later that we can actually register
3:38 a global config file for our user profile
3:41 and not have to pass this config flag or path or anything,
3:44 it will just automatically find and always use it, which is definitely recommended.
3:48 But periodically you might want to say well what's this look like
3:51 without my config file on a bare machine,
3:54 so --default-config you can get lots of debug output kind of like verbose
3:58 and you can feed that to a file so great for debugging
4:01 maybe for continuous integration as well,
4:03 not really sure about that but definitely good
4:06 if you want t try debug what you're working on and save it to a file.
4:09 Anyone see this message -h