forked from superfly/flyctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.go
36 lines (26 loc) · 1.01 KB
/
dashboard.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
package cmd
import (
"fmt"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/cmdctx"
"github.com/superfly/flyctl/docstrings"
"github.com/skratchdot/open-golang/open"
)
func newDashboardCommand(client *client.Client) *Command {
dashboardStrings := docstrings.Get("dashboard")
dashboardCmd := BuildCommandKS(nil, runDashboard, dashboardStrings, client, requireSession, requireAppName)
dashboardCmd.Aliases = []string{"dash"}
dashMetricsStrings := docstrings.Get("dashboard.metrics")
BuildCommandKS(dashboardCmd, runDashboardMetrics, dashMetricsStrings, client, requireSession, requireAppName)
return dashboardCmd
}
func runDashboard(cmdCtx *cmdctx.CmdContext) error {
return runDashboardOpen(cmdCtx, "https://fly.io/apps/"+cmdCtx.AppName)
}
func runDashboardMetrics(cmdCtx *cmdctx.CmdContext) error {
return runDashboardOpen(cmdCtx, "https://fly.io/apps/"+cmdCtx.AppName+"/metrics")
}
func runDashboardOpen(ctx *cmdctx.CmdContext, url string) error {
fmt.Println("Opening", url)
return open.Run(url)
}