-
-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shared variables #716
Comments
I find it a bit heavy-handed to write a context hook in order to add a variable. It doesn't allow default answers to depend on unprompted variables. |
For the time being, you already know the workarounds we have. However, you inspired me to write #718. Let's close this one. Thanks! |
you can have unprompted variables with
Works fine for me. |
@FlorianLudwig |
@FlorianLudwig, that is my current workaround. |
In order to factor out common calculations, especially amongst file and directory names, it would be useful to be able to define variables in
copier.yml
whose values are calculated based on answers or other variables.For example, when creating a template for a Java project, based on the name of the project, I would like to calculate the name of the root package, and also the path of the root package.
The root package variable would be referred to by multiple files.
The root package directory must be calculated this way since you cannot have a filename with a slash (
/
).Describe the solution you'd like
I suggest adding support for defining variables in
copier.yml
in a similar way as defining questions. The two are distinguished in some way, perhaps by a prefix such as a double underscore (__
) or by a key such ashidden: true
. I suggest that it be possible to mix defining variables and questions such that a question definition can refer to prior variables.Describe alternatives you've considered
This feature is called Private Variables in Cookicutter.
An obvious workaround is to define questions with default values. This is unsatisfactory because this forces users to read the trivial question and decide to hit the enter key, which adds unnecessary overhead and
Additional context
The given example refers to Java, but templates for other programming languages, including Python, could have similar issues.
The text was updated successfully, but these errors were encountered: