Replies: 2 comments 1 reply
|
Apologies, I just realized I asked this exact question a while back: https://github.com/orgs/copier-org/discussions/1009 That said, I’d still like to know whether you’d consider adding a flag or setting that lets users opt‑in to saving those computed values. I’m exactly sure how inline imports would solve the issue, and using ContextHooks feels a bit hacky for my situation (I maintain several templates, some of which generate other templates). |
|
I also want to save I have some values which are common 95% of the time. They are very specialized and I don't want to bother the user to always answer it. If someone wants to set it, they must pass it from the command line. The problem is that this question that has Here is where it caused a real problem for me: I have a question that is a The problem is that when I run "copier update" and it tries to run the old version, it uses the default true value and get the data from the json. It doesn't have my new selected choice as an option. It exists just in the database. It works just if I select options that are present in the json file. BTW, thanks for the last update that displays the invalid choice. |
Uh oh!
There was an error while loading. Please reload this page.
Context and use case
In my Copier template I have a few questions that are always set with
when: false. Their sole purpose is to compute a value based on a previous answer from the user. I do this to prevent the user from ever seeing or editing the derived value and therefore avoid errors when that value is later used.Example: The project name can be any string, but the corresponding Python module name must follow a stricter convention (e.g., no dashes). I compute a sanitized module name from the project name so that the user cannot accidentally supply an invalid module name.
Problem
Since some Copier release, the values of such “hidden” questions are no longer written to the answers file. This creates a problem for me because I parse that file programmatically and depend on those computed values for later processing. Although I could recalculate them myself, doing the computation outside of Copier risks inconsistencies.
Question
Is there a way to make Copier persist the values of these computed questions in the answers.yml file? If not, would you consider adding a setting or flag that lets users explicitly opt‑in to saving such hidden questions to the answers file? (if you'd be ok, I can probably contibute that change).
All reactions