-
Notifications
You must be signed in to change notification settings - Fork 90
/
uninstall.go
46 lines (41 loc) · 1016 Bytes
/
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
45
46
package granted
import (
"os"
"github.com/AlecAivazis/survey/v2"
"github.com/common-fate/clio"
"github.com/common-fate/granted/pkg/alias"
"github.com/common-fate/granted/pkg/config"
"github.com/urfave/cli/v2"
)
var UninstallCommand = cli.Command{
Name: "uninstall",
Usage: "Remove all Granted configuration",
Action: func(c *cli.Context) error {
withStdio := survey.WithStdio(os.Stdin, os.Stderr, os.Stderr)
in := &survey.Confirm{
Message: "Are you sure you want to remove your Granted config?",
Default: true,
}
var confirm bool
err := survey.AskOne(in, &confirm, withStdio)
if err != nil {
return err
}
if confirm {
err = alias.UninstallDefaultShellAlias()
if err != nil {
clio.Error(err.Error())
}
grantedFolder, err := config.GrantedConfigFolder()
if err != nil {
return err
}
err = os.RemoveAll(grantedFolder)
if err != nil {
return err
}
clio.Successf("Removed Granted config folder %s\n", grantedFolder)
}
return nil
},
}