--default should just ask for missing answers, regardless of whether there's a default answer in the template
ssteinerx opened this issue · comments
Actual Situation
It is an error for --defaults to be used if there is no default answer for a question and where there is no previously specified answer.
This will happen on e.g. a regeneration where new question without a default answer was added to the template, or on a new project.
Desired Situation
It would seem more useful to just ask if there's no previous answer, regardless of whether a default answer is provided by the template's copier.yml.
I'm not sure what generating an error in this case is attempting to prevent.
Proposed solution
Just ask for the missing data.
That there's no default answer doesn't seem relevant; if the data is missing, ask for it.
This allows --defaults to be used in all cases and just seems like the right behaviour to me.
Isn't that what -A
does?
AFAIK, -A can only be run if there's already an answers file. The object of the exercise is to be able to use the same command to generate or regenerate while testing to zoom through all the questions that have default answers to only have to answer the ones with no defaults.
Sometimes, when I have unexpected results, I iterate repeatedly; sometimes I kill the output, sometimes I don't. I just want a single command to pick the defaults and get on with it as quickly as possible.
So are you talking about initial copies, or about updates? I'm confused
So are you talking about initial copies, or about updates? I'm confused
Both. I just want one command to serve whether or not the project has been previously generated. Sometimes I'm overwriting a previous run, sometimes I just delete it to get a fresh regeneration.
If I use --defaults
, then I don't care about the answers to the questions, I am tweaking a template or something and whatever the default (or previous) answer is is fine.
Basically, if --defaults
just asked for an answer to question without either a default or a previous answer, instead of terminating with an exception, then --default
could be used in either case to breeze past most or all of the questions by using defaults provided in copier.yaml
or by using those provided during a prior run.
When running from a CI engine I don't want any prompting to occur, it will just cause the job to hang. I such a scenario the only reasonable thing to do if values are missing is to fail immediately.
I'm not saying whether the current combination of options and missing values is the best. The CI use case could also be handled with an explicit --non-interactive
option of some form.
I such a scenario the only reasonable thing to do if values are missing is to fail immediately
Only if the question is required or an empty answer fails validation, right?
Did you make sure about that in your template?
Could you please provide a sample template to replay the problem?
I did not experience the problem.
I'm simply pointing out that if --default
stops failing in case of missing values, then there should be another way to guarantee that copier
does not go into interactive mode and hangs waiting for input. Anyway an explicit option to prevent interactive mode is probably the best.
AFAIK that won't happen. This code covers your use case:
Line 447 in 6b878c8
Please reopen if you cn reproduce it and provide steps. Thanks!