forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.go
More file actions
57 lines (46 loc) · 1.21 KB
/
Copy pathstatus.go
File metadata and controls
57 lines (46 loc) · 1.21 KB
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
package cmd
import (
"context"
"fmt"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/errors"
"github.com/railwayapp/cli/ui"
)
func (h *Handler) Status(ctx context.Context, req *entity.CommandRequest) error {
projectCfg, err := h.ctrl.GetProjectConfigs(ctx)
if err != nil {
return err
}
project, err := h.ctrl.GetProject(ctx, projectCfg.Project)
if err != nil {
return err
}
if project != nil {
fmt.Printf("Project: %s\n", ui.Bold(fmt.Sprint(ui.MagentaText(project.Name))))
environment, err := h.ctrl.GetCurrentEnvironment(ctx)
if err != nil {
return err
}
fmt.Printf("Environment: %s\n", ui.Bold(fmt.Sprint(ui.BlueText(environment.Name))))
if len(project.Plugins) > 0 {
fmt.Printf("Plugins:\n")
for i := range project.Plugins {
plugin := project.Plugins[i]
if plugin.Name == "env" {
// legacy plugin
continue
}
fmt.Printf("%s\n", ui.Bold(fmt.Sprint(ui.GrayText(plugin.Name))))
}
}
if len(project.Services) > 0 {
fmt.Printf("Services:\n")
for i := range project.Services {
fmt.Printf("%s\n", ui.Bold(fmt.Sprint(ui.GrayText(project.Services[i].Name))))
}
}
} else {
fmt.Println(errors.ProjectConfigNotFound)
}
return nil
}