This commit is contained in:
david 2024-03-02 00:00:01 +08:00
parent b7102b43b7
commit 8ccc60327d
3 changed files with 12 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import (
"git.apinb.com/bsm-sdk/engine/vars"
"github.com/modood/table"
"github.com/spf13/cobra"
"github.com/subchen/go-tableify"
)
type JSONData struct {
@ -37,14 +38,14 @@ type ActionsReleases struct {
}
type PsTable struct {
ServiceKey string `table:"Service Key"`
ServiceKey string `tableify:"Service Key"`
Origin string
Status string
PID string
Performance string
CurrentVersion string `table:"Current Version"`
RegisterVersion string `table:"Register Version"`
UpdatedAt string `table:"Updated At"`
CurrentVersion string `tableify:"Current Version"`
RegisterVersion string `tableify:"Register Version"`
UpdatedAt string `tableify:"Updated At"`
}
var psCmd = &cobra.Command{
@ -79,6 +80,10 @@ func psExecute() {
}
// Output to stdout
t := tableify.New()
t.SetHeadersFromStruct(new(PsTable))
t.AddRowObjectList(pt)
t.Print()
table.Output(pt)
}

1
go.mod
View File

@ -17,5 +17,6 @@ require (
github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19
github.com/modood/table v0.0.0-20220527013332-8d47e76dad33
github.com/spf13/cobra v1.8.0
github.com/subchen/go-tableify v1.1.0
gorm.io/gorm v1.25.7 // indirect
)

2
go.sum
View File

@ -20,6 +20,8 @@ github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/subchen/go-tableify v1.1.0 h1:VUCCHfXlttR5LhjjEmCThdI0UdYKr/7OnOey78UClrY=
github.com/subchen/go-tableify v1.1.0/go.mod h1:a4dTYdYueMaCd4MU4V7q9XDjkDhQ/EhlKyQb4WaSCWw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=