-
Notifications
You must be signed in to change notification settings - Fork 7
/
stop.go
63 lines (47 loc) · 1.3 KB
/
stop.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
package presenters
import (
"github.com/recode-sh/cli/internal/features"
)
type StopViewDataContent struct {
ShowAsWarning bool
Message string
}
type StopViewData struct {
Error *ViewableError
Content StopViewDataContent
}
type StopViewer interface {
View(StopViewData)
}
type StopPresenter struct {
viewableErrorBuilder ViewableErrorBuilder
viewer StopViewer
}
func NewStopPresenter(
viewableErrorBuilder ViewableErrorBuilder,
viewer StopViewer,
) StopPresenter {
return StopPresenter{
viewableErrorBuilder: viewableErrorBuilder,
viewer: viewer,
}
}
func (s StopPresenter) PresentToView(response features.StopResponse) {
viewData := StopViewData{}
if response.Error == nil {
devEnvName := response.Content.DevEnvName
devEnvAlreadyStopped := response.Content.DevEnvAlreadyStopped
viewDataMessage := "The development environment \"" + devEnvName + "\" was stopped."
if devEnvAlreadyStopped {
viewDataMessage = "The development environment \"" + devEnvName + "\" is already stopped. Nothing to do."
}
viewData.Content = StopViewDataContent{
ShowAsWarning: devEnvAlreadyStopped,
Message: viewDataMessage,
}
s.viewer.View(viewData)
return
}
viewData.Error = s.viewableErrorBuilder.Build(response.Error)
s.viewer.View(viewData)
}