From 8ccc60327d4dfbc02891e99b3b1dcb941f3f05a4 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 2 Mar 2024 00:00:01 +0800 Subject: [PATCH] dev --- cmd/ps.go | 13 +++++++++---- go.mod | 1 + go.sum | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/ps.go b/cmd/ps.go index 6d653f7..a0e6ba4 100644 --- a/cmd/ps.go +++ b/cmd/ps.go @@ -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) } diff --git a/go.mod b/go.mod index e6a5e73..cff78bf 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index c2dea66..fd00582 100644 --- a/go.sum +++ b/go.sum @@ -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=