Skip to content

Commit

Permalink
feat: Add verify.exclude configuration variable
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Feb 22, 2022
1 parent 5f39fec commit 2451314
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ The following configuration variables are available:
| `status` | `exclude` | []string | *none* | Entry types to exclude from status |
| `template` | `options` | []string | `["missingkey=error"]` | Template options |
| `vault` | `command` | string | `vault` | Vault CLI command |
| `verify` | `exclude` | []string | *none* | Entry types to exclude from verify |
6 changes: 3 additions & 3 deletions pkg/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ type Config struct {
Git gitCmdConfig `mapstructure:"git"`
Merge mergeCmdConfig `mapstructure:"merge"`
Status statusCmdConfig `mapstructure:"status"`
Verify verifyCmdConfig `mapstructure:"verify"`

// Command configurations, not settable in the config file.
apply applyCmdConfig
Expand All @@ -148,7 +149,6 @@ type Config struct {
state stateCmdConfig
update updateCmdConfig
upgrade upgradeCmdConfig
verify verifyCmdConfig

// Version information.
version semver.Version
Expand Down Expand Up @@ -391,8 +391,8 @@ func newConfig(options ...configOption) (*Config, error) {
owner: gitHubOwner,
repo: gitHubRepo,
},
verify: verifyCmdConfig{
exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
Verify: verifyCmdConfig{
Exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll &^ chezmoi.EntryTypeScripts),
recursive: true,
},
Expand Down
16 changes: 8 additions & 8 deletions pkg/cmd/verifycmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type verifyCmdConfig struct {
exclude *chezmoi.EntryTypeSet
Exclude *chezmoi.EntryTypeSet
include *chezmoi.EntryTypeSet
init bool
recursive bool
Expand All @@ -28,20 +28,20 @@ func (c *Config) newVerifyCmd() *cobra.Command {
}

flags := verifyCmd.Flags()
flags.VarP(c.verify.exclude, "exclude", "x", "Exclude entry types")
flags.VarP(c.verify.include, "include", "i", "Include entry types")
flags.BoolVar(&c.verify.init, "init", c.update.init, "Recreate config file from template")
flags.BoolVarP(&c.verify.recursive, "recursive", "r", c.verify.recursive, "Recurse into subdirectories")
flags.VarP(c.Verify.Exclude, "exclude", "x", "Exclude entry types")
flags.VarP(c.Verify.include, "include", "i", "Include entry types")
flags.BoolVar(&c.Verify.init, "init", c.update.init, "Recreate config file from template")
flags.BoolVarP(&c.Verify.recursive, "recursive", "r", c.Verify.recursive, "Recurse into subdirectories")

return verifyCmd
}

func (c *Config) runVerifyCmd(cmd *cobra.Command, args []string) error {
errorOnWriteSystem := chezmoi.NewErrorOnWriteSystem(c.destSystem, chezmoi.ExitCodeError(1))
return c.applyArgs(cmd.Context(), errorOnWriteSystem, c.DestDirAbsPath, args, applyArgsOptions{
include: c.verify.include.Sub(c.verify.exclude),
init: c.verify.init,
recursive: c.verify.recursive,
include: c.Verify.include.Sub(c.Verify.Exclude),
init: c.Verify.init,
recursive: c.Verify.recursive,
umask: c.Umask,
})
}

0 comments on commit 2451314

Please sign in to comment.