forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environments.go
40 lines (32 loc) · 872 Bytes
/
environments.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
package cmd
import (
cmdconf "github.com/cloudfoundry/bosh-cli/cmd/config"
boshui "github.com/cloudfoundry/bosh-cli/ui"
boshtbl "github.com/cloudfoundry/bosh-cli/ui/table"
)
type EnvironmentsCmd struct {
config cmdconf.Config
ui boshui.UI
}
func NewEnvironmentsCmd(config cmdconf.Config, ui boshui.UI) EnvironmentsCmd {
return EnvironmentsCmd{config: config, ui: ui}
}
func (c EnvironmentsCmd) Run() error {
environments := c.config.Environments()
table := boshtbl.Table{
Content: "environments",
Header: []boshtbl.Header{
boshtbl.NewHeader("URL"),
boshtbl.NewHeader("Alias"),
},
SortBy: []boshtbl.ColumnSort{{Column: 0, Asc: true}},
}
for _, t := range environments {
table.Rows = append(table.Rows, []boshtbl.Value{
boshtbl.NewValueString(t.URL),
boshtbl.NewValueString(t.Alias),
})
}
c.ui.PrintTable(table)
return nil
}