Closed sunn4room closed 1 year ago
As mentioned in the previous issue that you opened (#2859), --autotemplate
is fragile and naive and should not be used.
What you're asking for here is a context-aware --autotemplate
that understands both the structure of the user's template variables and the structure of the file being converted into a template. This is extremely hard to do in a general way, and the proposed addition of a scope complicates the user interface to the point that it is likely easier for the user to create the template themselves.
If you can open a PR that implements what you want in a reliable way for all types of file then I would consider it, but in the short term I consider what you are requesting both effectively impossible and to have an unreasonably high ratio of implementation effort to user time saved.
@twpayne Should --autotemplate
be deprecated for removal in v3?
@twpayne Should
--autotemplate
be deprecated for removal in v3?
Yes, I think it was too ambitious and too fragile.
Problem reproduction
chezmoi data
original config
autotemplate generate
expect autotemplate
So, I think chezmoi should give
autotemplate
a scope, for examplechezmoi add --autotemplate=".color" xxx
Further discussion
I realize that
chezmoi re-add
will ignore the template file. It's natural that user should edit template file withchezmoi edit
. Ifautotemplate
has a scope, shouldchezmoi re-add
include the autotemplate file?