This is an automated email from the ASF dual-hosted git repository.
justxuewei pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 60127ccfc tablewrite cli show (#2237)
60127ccfc is described below
commit 60127ccfc19706bbd5cf0e698441efc33ef86521
Author: Leo Shen <[email protected]>
AuthorDate: Thu Mar 16 13:04:44 2023 +0800
tablewrite cli show (#2237)
---
tools/dubbogo-cli/cmd/show.go | 15 +++++++++++----
tools/dubbogo-cli/go.mod | 35 +----------------------------------
tools/dubbogo-cli/go.sum | 3 ++-
3 files changed, 14 insertions(+), 39 deletions(-)
diff --git a/tools/dubbogo-cli/cmd/show.go b/tools/dubbogo-cli/cmd/show.go
index 61426386b..991cbe5d1 100644
--- a/tools/dubbogo-cli/cmd/show.go
+++ b/tools/dubbogo-cli/cmd/show.go
@@ -20,10 +20,13 @@ package cmd
import (
"fmt"
"log"
+ "os"
+ "strings"
)
import (
"github.com/spf13/cobra"
+ "github.com/olekukonko/tablewriter"
)
import (
@@ -68,6 +71,9 @@ func show(cmd *cobra.Command, _ []string) {
panic(err)
}
+ table := tablewriter.NewWriter(os.Stdout)
+ table.SetHeader([]string{"Interface", "Method"})
+
if registry != "" {
registryFactory, ok := metadata.GetFactory(registry)
if !ok {
@@ -81,9 +87,9 @@ func show(cmd *cobra.Command, _ []string) {
fmt.Printf("======================\n")
fmt.Printf("Registry:\n")
for k, v := range methodsMap {
- fmt.Printf("interface: %s\n", k)
- fmt.Printf("methods: %v\n", v)
+ table.Append([]string{k, strings.Join(v, ", ")})
}
+ table.Render()
fmt.Printf("======================\n")
}
@@ -100,9 +106,10 @@ func show(cmd *cobra.Command, _ []string) {
fmt.Printf("======================\n")
fmt.Printf("MetadataCenter:\n")
for k, v := range methodsMap {
- fmt.Printf("interface: %s\n", k)
- fmt.Printf("methods: %v\n", v)
+ table.Append([]string{k, strings.Join(v, ", ")})
}
+ table.Render()
fmt.Printf("======================\n")
}
}
+
diff --git a/tools/dubbogo-cli/go.mod b/tools/dubbogo-cli/go.mod
index 9c29612ea..3f7af722f 100644
--- a/tools/dubbogo-cli/go.mod
+++ b/tools/dubbogo-cli/go.mod
@@ -15,39 +15,6 @@ require (
)
require (
- github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d //
indirect
- github.com/Workiva/go-datastructures v1.0.52 // indirect
- github.com/apache/dubbo-getty v1.4.7 // indirect
- github.com/buger/jsonparser v1.1.1 // indirect
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 //
indirect
- github.com/fsnotify/fsnotify v1.5.1 // indirect
- github.com/go-ole/go-ole v1.2.4 // indirect
- github.com/golang/snappy v0.0.4 // indirect
- github.com/gorilla/websocket v1.4.2 // indirect
- github.com/hashicorp/hcl v1.0.0 // indirect
- github.com/inconshreveable/mousetrap v1.0.0 // indirect
- github.com/jinzhu/copier v0.3.5 // indirect
- github.com/k0kubun/pp v3.0.1+incompatible // indirect
- github.com/magiconair/properties v1.8.5 // indirect
- github.com/mattn/go-colorable v0.1.12 // indirect
- github.com/mattn/go-isatty v0.0.14 // indirect
- github.com/mitchellh/mapstructure v1.4.3 // indirect
- github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
- github.com/pelletier/go-toml v1.9.4 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b //
indirect
- github.com/shirou/gopsutil v3.20.11+incompatible // indirect
- github.com/spf13/afero v1.6.0 // indirect
- github.com/spf13/cast v1.4.1 // indirect
- github.com/spf13/jwalterweatherman v1.1.0 // indirect
- github.com/spf13/pflag v1.0.5 // indirect
- github.com/subosito/gotenv v1.2.0 // indirect
- go.uber.org/multierr v1.6.0 // indirect
- go.uber.org/zap v1.21.0 // indirect
- golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
- golang.org/x/text v0.3.7 // indirect
- gopkg.in/ini.v1 v1.66.2 // indirect
- gopkg.in/yaml.v2 v2.4.0 // indirect
+ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5
gopkg.in/yaml.v3 v3.0.0 // indirect
)
diff --git a/tools/dubbogo-cli/go.sum b/tools/dubbogo-cli/go.sum
index a7ee05eb9..1ea61c23d 100644
--- a/tools/dubbogo-cli/go.sum
+++ b/tools/dubbogo-cli/go.sum
@@ -570,6 +570,7 @@ github.com/mattn/go-isatty v0.0.11/go.mod
h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA
github.com/mattn/go-isatty v0.0.12/go.mod
h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14
h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod
h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
+github.com/mattn/go-runewidth v0.0.2
h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=
github.com/mattn/go-runewidth v0.0.2/go.mod
h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod
h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.14/go.mod
h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
@@ -624,6 +625,7 @@ github.com/nxadm/tail v1.4.4/go.mod
h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI
github.com/oklog/oklog v0.3.2/go.mod
h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
github.com/oklog/run v1.0.0/go.mod
h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/ulid v1.3.1/go.mod
h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5
h1:58+kh9C6jJVXYjt8IE48G2eWl6BjwU5Gj0gqY84fy78=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod
h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod
h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.6.0/go.mod
h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -1414,7 +1416,6 @@ gopkg.in/yaml.v2 v2.4.0
h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod
h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod
h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod
h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=