forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen.go
More file actions
47 lines (38 loc) · 1 KB
/
Copy pathopen.go
File metadata and controls
47 lines (38 loc) · 1 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
package cmd
import (
"context"
"github.com/railwayapp/cli/entity"
)
func (h *Handler) Open(ctx context.Context, req *entity.CommandRequest) error {
projectId, err := h.cfg.GetProject()
if err != nil {
return err
}
environmentId, err := h.cfg.GetCurrentEnvironment()
if err != nil {
return err
}
// If an unknown subcommand is used, show help
if len(req.Args) > 0 {
return req.Cmd.Help()
}
if req.Cmd.Use == "open" {
return h.ctrl.OpenProjectInBrowser(ctx, projectId, environmentId)
}
return h.ctrl.OpenProjectPathInBrowser(ctx, projectId, environmentId, req.Cmd.Use)
}
func (h *Handler) OpenApp(ctx context.Context, req *entity.CommandRequest) error {
projectId, err := h.cfg.GetProject()
if err != nil {
return err
}
environmentId, err := h.cfg.GetCurrentEnvironment()
if err != nil {
return err
}
deployment, err := h.ctrl.GetLatestDeploymentForEnvironment(ctx, projectId, environmentId)
if err != nil {
return err
}
return h.ctrl.OpenStaticUrlInBrowser(deployment.StaticUrl)
}