/
uninstall.go
44 lines (39 loc) · 1.06 KB
/
uninstall.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package cmd
import (
"fmt"
"os"
"path/filepath"
"github.com/jumppad-labs/jumppad/pkg/utils"
"github.com/spf13/cobra"
)
var uninstallCmd = &cobra.Command{
Use: "uninstall",
Short: "Uninstall jumppad",
Long: `Uninstall jumppad`,
DisableFlagsInUseLine: true,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
// remove the config
fmt.Println("Removing Shipyard configuration from", utils.JumppadHome())
err := os.RemoveAll(utils.JumppadHome())
if err != nil {
fmt.Println("Error: Unable to remove jumppad configuration", err)
os.Exit(1)
}
// remove the binary
ep, _ := os.Executable()
cf, err := filepath.Abs(ep)
if err != nil {
fmt.Println("Error: Unable to remove jumppad application", err)
os.Exit(1)
}
fmt.Println("Removing jumppad application from", cf)
err = os.Remove(cf)
if err != nil {
fmt.Println("Error: Unable to remove jumppad application", err)
os.Exit(1)
}
fmt.Println("")
fmt.Println("jumppad successfully uninstalled")
},
}