Skip to content

Commit

Permalink
chore: Deprecate --autotemplate
Browse files Browse the repository at this point in the history
Remove `--autotemplate` from `chezmoi --help` and print a message when
it is used.

> > @twpayne Should `--autotemplate` be deprecated for removal in v3?
> Yes, I think it was too ambitious and too fragile.

Resolves twpayne#2873 and other related issues.
  • Loading branch information
halostatue authored and twpayne committed Mar 20, 2023
1 parent 10dc4a7 commit 23a09fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion assets/chezmoi.io/docs/reference/commands/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Add *target*s to the source state. If any target is already in the source
state, then its source state is replaced with its current state in the
destination directory.

## `--autotemplate`
## `--autotemplate` (deprecated)

Automatically generate a template by replacing strings that match variable
values from the `data` section of the config file with their respective config
Expand All @@ -17,6 +17,9 @@ This implies the `--template` option.
templates with unwanted variable substitutions. Carefully review any
templates it generates.

`--autotemplate` has been deprecated and will be removed in a future
release of chezmoi.

## `--encrypt`

Encrypt files using the defined encryption method.
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/addcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (c *Config) newAddCmd() *cobra.Command {
flags.BoolVarP(&c.Add.template, "template", "T", c.Add.template, "Add files as templates")
flags.BoolVar(&c.Add.TemplateSymlinks, "template-symlinks", c.Add.TemplateSymlinks, "Add symlinks with target in source or home dirs as templates") //nolint:lll

if err := flags.MarkDeprecated("autotemplate", "it will be removed in a future release"); err != nil {
panic(err)
}

registerExcludeIncludeFlagCompletionFuncs(addCmd)

return addCmd
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/testdata/scripts/addautotemplate.txtar
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# test that chezmoi add --autotemplate on a file with a replacement creates a template in the source directory
exec chezmoi add --autotemplate $HOME${/}.template
stderr 'deprecated'
cmp $CHEZMOISOURCEDIR/dot_template.tmpl golden/dot_template.tmpl

# test that chezmoi add --autotemplate on a symlink with a replacement creates a template in the source directory
Expand Down

0 comments on commit 23a09fc

Please sign in to comment.