forked from vmware-archive/fly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teams.go
47 lines (36 loc) · 735 Bytes
/
teams.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
package commands
import (
"os"
"sort"
"github.com/concourse/fly/rc"
"github.com/concourse/fly/ui"
"github.com/fatih/color"
)
type TeamsCommand struct{}
func (command *TeamsCommand) Execute([]string) error {
target, err := rc.LoadTarget(Fly.Target)
if err != nil {
return err
}
err = target.Validate()
if err != nil {
return err
}
teams, err := target.Client().ListTeams()
if err != nil {
return err
}
table := ui.Table{
Headers: ui.TableRow{
{Contents: "name", Color: color.New(color.Bold)},
},
}
for _, t := range teams {
row := ui.TableRow{
{Contents: t.Name},
}
table.Data = append(table.Data, row)
}
sort.Sort(table.Data)
return table.Render(os.Stdout, Fly.PrintTableHeaders)
}