Skip to content

Commit

Permalink
Merge pull request #49 from twpayne/rename-functions
Browse files Browse the repository at this point in the history
Rename functions
  • Loading branch information
twpayne authored Dec 2, 2018
2 parents 12ce5b9 + 89440ce commit aef1e00
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
4 changes: 2 additions & 2 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions cmd/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/forget.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit aef1e00

Please sign in to comment.