Using and Mastering Cookiecutter Transcripts
Chapter: Creating Cookiecutter templates
Lecture: Default values and required values

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's take a moment and focus on required values.
0:04 Basically making sure that user enters something.
0:07 Now, we're going to try and see that we at least
0:11 can get to like a blank value thing, but we won't really be able
0:14 to solve this problem until we look at one more feature later on,
0:17 but let's give it a shot here and then we'll come back and look at it.
0:20 So I've done a little bit of reorganizing here, I've saved off the work
0:25 we have done so far into cookiecutter-colors-v1 and now,
0:28 this one I've changes a little bit, notice since that it had been project name
0:32 we have project slug here, and over in the json,
0:35 I've added that little trick to take the project name and generate a slug from it,
0:40 so that we have a little more reliability, for the file or the project,
0:44 the folder that we generate because,
0:47 if we have things like colons and slashes and stuff
0:50 it's not going to work out so well for us.
0:52 So let's suppose that we want creator to be a required value,
0:56 maybe we could start like this, let's suppose
0:58 those two have to be required values,
1:01 one possibility we say let's put in nothing and see what happens here,
1:06 so if I run this, cookicecutter cookiecutter-colors it's going to ask some questions,
1:10 my project I'll say the best ever and you can see the best ever
1:14 how cool is that, right, so we'll take that default and creator,
1:17 well, what we would like for it to do is say you must specify a creator name,
1:20 you must specify color name, and now if we open up the best ever,
1:26 like this, you can see up here at the top where it used to say blue,
1:31 it's just empty, right, so much for required value,
1:35 because, these empty values just went in as empty values.
1:38 Well, we can try one more thing, maybe we can have
1:41 something like required here, yeah.
1:44 that is probably going to do it, let's try one more time,
1:46 run the same code here, like this, alright,
1:50 we'll just take the defaults blank and required, no, still nothing.
1:54 Although, in a slightly better way, we should be able to see
1:58 that our blue is now required.
2:01 Okay, so this is not working, but the one half that we do want is
2:04 we should be able to use either of these, we want to create a system
2:07 where we can say creator is blank, and somehow maybe know that
2:12 that is required, we want to be able to say favorite_color=required
2:15 and they are not allowed to enter, something else.
2:18 we could see that we could give them a choice here,
2:21 and then they would have to choose from the list, like blue yellow green red,
2:24 but if we want the full rainbow, the entire spectrum of colors,
2:28 well, we're going to have to do something more interesting than that.