Skip to content

Commit 6bee444

Browse files
enx: revert and logs
1 parent c2349aa commit 6bee444

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

cmd/cleanup.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,31 @@ import (
44
"fmt"
55

66
"github.com/RohitRavindra-dev/devlocal/internal/filesystem"
7+
"github.com/RohitRavindra-dev/devlocal/internal/service/revert"
78
"github.com/spf13/cobra"
89
)
910

1011
var cleanupCmd = &cobra.Command{
1112
Use: "cleanup",
1213
Short: "Cleanup devlocal setup",
14+
PreRunE: func(cmd *cobra.Command, args []string) error {
15+
fmt.Println("[Started] to revert devlocal changes")
16+
// check for setup
17+
return filesystem.ValidateDevLocalFilesystem()
18+
},
1319
RunE: func(cmd *cobra.Command, args []string) error {
1420
fmt.Println("Cleaning up setup")
1521
//call revert
22+
if err := revert.Run(); err != nil {
23+
fmt.Println("[Errored] while trying to cleanup devlocal setup")
24+
return err
25+
}
1626
// remove devlocal files
1727
fileTeardownError := filesystem.TearDownDevLocalFilesystem()
1828
if fileTeardownError != nil {
1929
return fileTeardownError
2030
}
21-
fmt.Println("Cleanup completed, ciao!")
31+
fmt.Println("[Completed] Cleanup, ciao!")
2232
return nil
2333
},
2434
}

internal/filesystem/teardown.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ import (
88
)
99

1010
func TearDownDevLocalFilesystem() error {
11-
fmt.Printf("Removing %s and all underlying evidence\n", config.PROJECT_ROOT)
11+
fmt.Printf("[Running] teardown of %s and all underlying evidence\n", config.PROJECT_ROOT)
1212
return os.RemoveAll(config.PROJECT_ROOT)
1313
}

0 commit comments

Comments
 (0)