-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.go
77 lines (60 loc) · 1.79 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package presenters
import (
"fmt"
"github.com/yolo-sh/cli/internal/constants"
"github.com/yolo-sh/cli/internal/features"
)
type UninstallViewDataContent struct {
ShowAsWarning bool
Message string
Subtext string
}
type UninstallViewData struct {
Error *ViewableError
Content UninstallViewDataContent
}
type UninstallViewer interface {
View(UninstallViewData)
}
type UninstallPresenter struct {
viewableErrorBuilder ViewableErrorBuilder
viewer UninstallViewer
}
func NewUninstallPresenter(
viewableErrorBuilder ViewableErrorBuilder,
viewer UninstallViewer,
) UninstallPresenter {
return UninstallPresenter{
viewableErrorBuilder: viewableErrorBuilder,
viewer: viewer,
}
}
func (u UninstallPresenter) PresentToView(response features.UninstallResponse) {
viewData := UninstallViewData{}
if response.Error == nil {
bold := constants.Bold
yoloAlreadyUninstalled := response.Content.YoloAlreadyUninstalled
viewDataMessage := response.Content.SuccessMessage
viewDataSubtext := fmt.Sprintf(
"If you want to remove Yolo entirely:\n\n"+
" - Remove the Yolo CLI (located at %s)\n\n"+
" - Remove the Yolo configuration (located at %s)\n\n"+
" - Unauthorize the Yolo application on GitHub by going to: %s",
bold(response.Content.YoloExecutablePath),
bold(response.Content.YoloConfigDirPath),
bold("https://github.com/settings/applications"),
)
if yoloAlreadyUninstalled {
viewDataMessage = response.Content.AlreadyUninstalledMessage
}
viewData.Content = UninstallViewDataContent{
ShowAsWarning: yoloAlreadyUninstalled,
Message: viewDataMessage,
Subtext: viewDataSubtext,
}
u.viewer.View(viewData)
return
}
viewData.Error = u.viewableErrorBuilder.Build(response.Error)
u.viewer.View(viewData)
}