mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-15 22:04:03 +02:00
25 lines
730 B
Go
25 lines
730 B
Go
package clihub
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/jedib0t/go-pretty/v6/table"
|
|
|
|
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/cstable"
|
|
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
|
"github.com/crowdsecurity/crowdsec/pkg/emoji"
|
|
)
|
|
|
|
func listHubItemTable(out io.Writer, wantColor string, title string, items []*cwhub.Item) {
|
|
t := cstable.NewLight(out, wantColor).Writer
|
|
t.AppendHeader(table.Row{"Name", fmt.Sprintf("%v Status", emoji.Package), "Version", "Local Path"})
|
|
|
|
for _, item := range items {
|
|
status := fmt.Sprintf("%v %s", item.State.Emoji(), item.State.Text())
|
|
t.AppendRow(table.Row{item.Name, status, item.State.LocalVersion, item.State.LocalPath})
|
|
}
|
|
|
|
t.SetTitle(title)
|
|
fmt.Fprintln(out, t.Render())
|
|
}
|