-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
64 lines (52 loc) · 1.45 KB
/
status.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
package cmd
import (
"fmt"
"github.com/gosuri/uitable"
"github.com/renehernandez/appfile/internal/errors"
"github.com/spf13/cobra"
)
type statusCmd struct {
*rootCmd
}
var (
statusLong = `Show status for apps defined in the appfile.
`
statusExample = ` # Status using defaults: appfile.yaml in current location, default environment and DIGITALOCEAN_ACCESS_TOKEN env var
appfile status
# Status using appfile.yaml in custom location, review environment and access token option
appfile status --file /path/to/appfile.yaml --environment review --access-token $TOKEN
# Status with debug output
appfile status --log-level debug`
)
func newStatusCmd(rootCmd *rootCmd) *cobra.Command {
status := statusCmd{
rootCmd: rootCmd,
}
cmd := &cobra.Command{
Use: "status",
Short: "Show status for apps defined in the appfile",
Long: statusLong,
Example: statusExample,
Run: func(cmd *cobra.Command, args []string) {
status.run()
},
}
return cmd
}
func (status *statusCmd) run() {
appfile := status.appfileFromSpec()
appsStatus, err := appfile.Status()
errors.CheckAndFail(err)
table := uitable.New()
table.Wrap = true
table.MaxColWidth = 80
for _, status := range appsStatus {
table.AddRow("Name:", status.Name)
table.AddRow("Status:", status.Status)
table.AddRow("Deployment ID:", status.DeploymentID)
table.AddRow("Updated:", status.UpdatedAt)
table.AddRow("URL:", status.URL)
table.AddRow("")
}
fmt.Println(table)
}