Repository: twpayne/chezmoi
Pull request #49 (2018-12-02 21:49:14)

Rename functions


Patch:
diff --git a/cmd/add.go b/cmd/add.go
index 4c299db4f..70ac3a36e 100644
--- a/cmd/add.go
+++ b/cmd/add.go
@@ -13,7 +13,7 @@ var addCommand = &cobra.Command{
 	Use:   "add",
 	Args:  cobra.MinimumNArgs(1),
 	Short: "Add an existing file or directory",
-	RunE:  makeRunE(config.runAddCommandE),
+	RunE:  makeRunE(config.runAddCommand),
 }
 
 // An AddCommandConfig is a configuration for the add command.
@@ -32,7 +32,7 @@ func init() {
 	persistentFlags.BoolVarP(&config.add.template, "template", "T", false, "add files as templates")
 }
 
-func (c *Config) runAddCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
+func (c *Config) runAddCommand(fs vfs.FS, command *cobra.Command, args []string) error {
 	targetState, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/apply.go b/cmd/apply.go
index c58f7d01a..afc8233f0 100644
--- a/cmd/apply.go
+++ b/cmd/apply.go
@@ -8,14 +8,14 @@ import (
 var applyCommand = &cobra.Command{
 	Use:   "apply",
 	Short: "Update the actual state to match the target state",
-	RunE:  makeRunE(config.runApplyCommandE),
+	RunE:  makeRunE(config.runApplyCommand),
 }
 
 func init() {
 	rootCommand.AddCommand(applyCommand)
 }
 
-func (c *Config) runApplyCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
+func (c *Config) runApplyCommand(fs vfs.FS, command *cobra.Command, args []string) error {
 	actuator := c.getDefaultActuator(fs)
 	return c.applyArgs(fs, args, actuator)
 }
diff --git a/cmd/archive.go b/cmd/archive.go
index 9860b9503..f0a0a0bbf 100644
--- a/cmd/archive.go
+++ b/cmd/archive.go
@@ -12,14 +12,14 @@ var archiveCommand = &cobra.Command{
 	Use:   "archive",
 	Args:  cobra.NoArgs,
 	Short: "Write a tar archive of the target state to stdout",
-	RunE:  makeRunE(config.runArchiveCommandE),
+	RunE:  makeRunE(config.runArchiveCommand),
 }
 
 func init() {
 	rootCommand.AddCommand(archiveCommand)
 }
 
-func (c *Config) runArchiveCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
+func (c *Config) runArchiveCommand(fs vfs.FS, command *cobra.Command, args []string) error {
 	targetState, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/diff.go b/cmd/diff.go
index cd9e6432e..8050b3c9e 100644
--- a/cmd/diff.go
+++ b/cmd/diff.go
@@ -11,14 +11,14 @@ import (
 var diffCommand = &cobra.Command{
 	Use:   "diff",
 	Short: "Print the diff between the actual state and the target state",
-	RunE:  makeRunE(config.runDiffCommandE),
+	RunE:  makeRunE(config.runDiffCommand),
 }
 
 func init() {
 	rootCommand.AddCommand(diffCommand)
 }
 
-func (c *Config) runDiffCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
+func (c *Config) runDiffCommand(fs vfs.FS, command *cobra.Command, args []string) error {
 	actuator := chezmoi.NewLoggingActuator(os.Stdout, chezmoi.NewNullActuator())
 	return c.applyArgs(fs, args, actuator)
 }
diff --git a/cmd/dump.go b/cmd/dump.go
index b2561417d..892e75876 100644
--- a/cmd/dump.go
+++ b/cmd/dump.go
@@ -12,14 +12,14 @@ import (
 var dumpCommand = &cobra.Command{
 	Use:   "dump",
 	Short: "Dump the target state",
-	RunE:  makeRunE(config.runDumpCommandE),
+	RunE:  makeRunE(config.runDumpCommand),
 }
 
 func init() {
 	rootCommand.AddCommand(dumpCommand)
 }
 
-func (c *Config) runDumpCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
+func (c *Config) runDumpCommand(fs vfs.FS, command *cobra.Command, args []string) error {
 	targetState, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/edit.go b/cmd/edit.go
index 1b07bfe3f..ce1df36f3 100644
--- a/cmd/edit.go
+++ b/cmd/edit.go
@@ -16,7 +16,7 @@ var editCommand = &cobra.Command{
 	Use:   "edit",
 	Args:  cobra.MinimumNArgs(1),
 	Short: "Edit a file",
-	RunE:  makeRunE(config.runEditCommandE),
+	RunE:  makeRunE(config.runEditCommand),
 }
 
 type editCommandConfig struct {
@@ -34,7 +34,7 @@ func init() {
 	persistentFlags.BoolVarP(&config.edit.prompt, "prompt", "p", false, "prompt before applying (implies --diff)")
 }
 
-func (c *Config) runEditCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
+func (c *Config) runEditCommand(fs vfs.FS, command *cobra.Command, args []string) error {
 	if c.edit.prompt {
 		c.edit.diff = true
 	}
diff --git a/cmd/forget.go b/cmd/forget.go
index a2ac8af92..fd218a883 100644
--- a/cmd/forget.go
+++ b/cmd/forget.go
@@ -11,14 +11,14 @@ var forgetCommand = &cobra.Command{
 	Use:   "forget",
 	Args:  cobra.MinimumNArgs(1),
 	Short: "Forget a file or directory",
-	RunE:  makeRunE(config.runForgetCommandE),
+	RunE:  makeRunE(config.runForgetCommand),
 }
 
 func init() {
 	rootCommand.AddCommand(forgetCommand)
 }
 
-func (c *Config) runForgetCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
+func (c *Config) runForgetCommand(fs vfs.FS, command *cobra.Command, args []string) error {
 	targetState, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/remove.go b/cmd/remove.go
index 8e53fb3d4..ff0503f31 100644
--- a/cmd/remove.go
+++ b/cmd/remove.go
@@ -13,28 +13,28 @@ var removeCommand = &cobra.Command{
 	Aliases: []string{"rm"},
 	Args:    cobra.MinimumNArgs(1),
 	Short:   "Remove a file or directory",
-	RunE:    makeRunE(runRemoveCommandE),
+	RunE:    makeRunE(config.runRemoveCommand),
 }
 
 func init() {
 	rootCommand.AddCommand(removeCommand)
 }
 
-func runRemoveCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
-	targetState, err := config.getTargetState(fs)
+func (c *Config) runRemoveCommand(fs vfs.FS, command *cobra.Command, args []string) error {
+	targetState, err := c.getTargetState(fs)
 	if err != nil {
 		return err
 	}
-	sourceNames, err := config.getSourceNames(targetState, args)
+	sourceNames, err := c.getSourceNames(targetState, args)
 	if err != nil {
 		return err
 	}
-	actuator := config.getDefaultActuator(fs)
+	actuator := c.getDefaultActuator(fs)
 	for i, targetFileName := range args {
-		if err := actuator.RemoveAll(filepath.Join(config.TargetDir, targetFileName)); err != nil && !os.IsNotExist(err) {
+		if err := actuator.RemoveAll(filepath.Join(c.TargetDir, targetFileName)); err != nil && !os.IsNotExist(err) {
 			return err
 		}
-		if err := actuator.RemoveAll(filepath.Join(config.SourceDir, sourceNames[i])); err != nil && !os.IsNotExist(err) {
+		if err := actuator.RemoveAll(filepath.Join(c.SourceDir, sourceNames[i])); err != nil && !os.IsNotExist(err) {
 			return err
 		}
 	}
diff --git a/cmd/verify.go b/cmd/verify.go
index 10421a052..b72fdc578 100644
--- a/cmd/verify.go
+++ b/cmd/verify.go
@@ -11,14 +11,14 @@ import (
 var verifyCommand = &cobra.Command{
 	Use:   "verify",
 	Short: "Exit with success if the actual state matches the target state, fail otherwise",
-	RunE:  makeRunE(config.runVerifyCommandE),
+	RunE:  makeRunE(config.runVerifyCommand),
 }
 
 func init() {
 	rootCommand.AddCommand(verifyCommand)
 }
 
-func (c *Config) runVerifyCommandE(fs vfs.FS, command *cobra.Command, args []string) error {
+func (c *Config) runVerifyCommand(fs vfs.FS, command *cobra.Command, args []string) error {
 	actuator := chezmoi.NewAnyActuator(chezmoi.NewNullActuator())
 	if err := c.applyArgs(fs, args, actuator); err != nil {
 		return err
diff --git a/cmd/version.go b/cmd/version.go
index 046673fe0..4aeab03d9 100644
--- a/cmd/version.go
+++ b/cmd/version.go
@@ -11,14 +11,14 @@ var versionCommand = &cobra.Command{
 	Use:   "version",
 	Args:  cobra.NoArgs,
 	Short: "Print version",
-	RunE:  makeRunE(config.runVersionCommandE),
+	RunE:  makeRunE(config.runVersionCommand),
 }
 
 func init() {
 	rootCommand.AddCommand(versionCommand)
 }
 
-func (c *Config) runVersionCommandE(fs vfs.FS, cmd *cobra.Command, args []string) error {
+func (c *Config) runVersionCommand(fs vfs.FS, cmd *cobra.Command, args []string) error {
 	fmt.Printf("Version: %s Commit: %s Date: %s\n", c.version.Version, c.version.Commit, c.version.Date)
 	return nil
 }


Test patch:
diff --git a/cmd/add_test.go b/cmd/add_test.go
index 40f1957d3..561d3979b 100644
--- a/cmd/add_test.go
+++ b/cmd/add_test.go
@@ -144,8 +144,8 @@ func TestAddCommand(t *testing.T) {
 			if err != nil {
 				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
 			}
-			if err := c.runAddCommandE(fs, nil, tc.args); err != nil {
-				t.Errorf("c.runAddCommandE(fs, nil, %+v) == %v, want <nil>", tc.args, err)
+			if err := c.runAddCommand(fs, nil, tc.args); err != nil {
+				t.Errorf("c.runAddCommand(fs, nil, %+v) == %v, want <nil>", tc.args, err)
 			}
 			vfst.RunTests(t, fs, "", tc.tests)
 		})