-
Notifications
You must be signed in to change notification settings - Fork 0
/
listinstalled.go
33 lines (28 loc) · 965 Bytes
/
listinstalled.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
package registry
import (
"github.com/alecthomas/kong"
"github.com/olekukonko/tablewriter"
)
type ListInstalledRegistries struct {
r *PluginRegistries
}
func (l *ListInstalledRegistries) BeforeApply() error {
var err error
l.r, err = LoadFromDisk()
return err
}
func (l *ListInstalledRegistries) Run(ctx *kong.Context) error {
registries := l.r.GetAll()
table := tablewriter.NewWriter(ctx.Stdout)
table.SetAutoWrapText(false)
table.SetHeader([]string{"Registry Name", "URL"})
table.SetHeaderAlignment(tablewriter.ALIGN_CENTER)
table.SetHeaderColor(tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiWhiteColor}, tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiWhiteColor})
table.SetColumnColor(tablewriter.Colors{tablewriter.Bold, tablewriter.FgCyanColor}, tablewriter.Colors{tablewriter.FgYellowColor})
table.SetHeaderLine(true)
for n, r := range registries {
table.Append([]string{n, r.URL.String()})
}
table.Render()
return nil
}