From 8a20f91af83752b61fbfd35fc153257bba2f2ddf Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Mon, 5 Feb 2024 18:29:42 +0100 Subject: [PATCH] feat: Add update.apply configuration variable --- .../docs/reference/configuration-file/variables.md.yaml | 4 ++++ internal/cmd/config.go | 2 +- internal/cmd/updatecmd.go | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml index c685a778ca6..b31dcf8f5e1 100644 --- a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml +++ b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml @@ -386,6 +386,10 @@ sections: default: '`vault`' description: Vault CLI command update: + apply: + type: 'bool' + default: '`true`' + description: Apply after pulling args: type: '[]string' description: Extra args to update command diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 7d04a1ba39f..9e3fc9480bd 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -2779,8 +2779,8 @@ func newConfigFile(bds *xdg.BaseDirectorySpecification) ConfigFile { recursive: true, }, Update: updateCmdConfig{ + Apply: true, RecurseSubmodules: true, - apply: true, filter: chezmoi.NewEntryTypeFilter(chezmoi.EntryTypesAll, chezmoi.EntryTypesNone), recursive: true, }, diff --git a/internal/cmd/updatecmd.go b/internal/cmd/updatecmd.go index c80e72a6884..798fb6dc3fb 100644 --- a/internal/cmd/updatecmd.go +++ b/internal/cmd/updatecmd.go @@ -12,8 +12,8 @@ import ( type updateCmdConfig struct { Command string `json:"command" mapstructure:"command" yaml:"command"` Args []string `json:"args" mapstructure:"args" yaml:"args"` + Apply bool `json:"apply" mapstructure:"apply" yaml:"apply"` RecurseSubmodules bool `json:"recurseSubmodules" mapstructure:"recurseSubmodules" yaml:"recurseSubmodules"` - apply bool filter *chezmoi.EntryTypeFilter init bool recursive bool @@ -37,7 +37,7 @@ func (c *Config) newUpdateCmd() *cobra.Command { } flags := updateCmd.Flags() - flags.BoolVarP(&c.Update.apply, "apply", "a", c.Update.apply, "Apply after pulling") + flags.BoolVarP(&c.Update.Apply, "apply", "a", c.Update.Apply, "Apply after pulling") flags.VarP(c.Update.filter.Exclude, "exclude", "x", "Exclude entry types") flags.VarP(c.Update.filter.Include, "include", "i", "Include entry types") flags.BoolVar(&c.Update.init, "init", c.Update.init, "Recreate config file from template") @@ -94,7 +94,7 @@ func (c *Config) runUpdateCmd(cmd *cobra.Command, args []string) error { } } - if c.Update.apply { + if c.Update.Apply { if err := c.applyArgs(cmd.Context(), c.destSystem, c.DestDirAbsPath, args, applyArgsOptions{ cmd: cmd, filter: c.Update.filter,