Skip to content

Commit

Permalink
feat: Add update.apply configuration variable
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Feb 5, 2024
1 parent 4443acf commit 8a20f91
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/config.go
Expand Up @@ -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,
},
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/updatecmd.go
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8a20f91

Please sign in to comment.