forked from convox/rack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathracks.go
39 lines (33 loc) · 777 Bytes
/
racks.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
package main
import (
"fmt"
"github.com/convox/rack/cmd/convox/stdcli"
"gopkg.in/urfave/cli.v1"
)
func init() {
stdcli.RegisterCommand(cli.Command{
Name: "racks",
Description: "list your Convox racks",
Usage: "",
Action: cmdRacks,
})
}
func cmdRacks(c *cli.Context) error {
if len(c.Args()) > 0 {
return stdcli.Error(fmt.Errorf("`convox racks` does not take arguments. Perhaps you meant `convox rack`?"))
}
racks, err := rackClient(c).Racks()
if err != nil {
return stdcli.Error(err)
}
t := stdcli.NewTable("RACK", "STATUS")
for _, rack := range racks {
name := rack.Name
if rack.Organization != nil {
name = fmt.Sprintf("%s/%s", rack.Organization.Name, name)
}
t.AddRow(name, rack.Status)
}
t.Print()
return nil
}