Skip to content

Commit

Permalink
Replace tablewriter go deps
Browse files Browse the repository at this point in the history
Extend table configuration with SetTrimWhiteSpaceAtEOL, which
removes trailing whitespaces, change order of fields so the
longest string will be the last one

Closes criblio#399
  • Loading branch information
michalbiesek committed Aug 9, 2021
1 parent 1182b46 commit 06988b7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ require (
k8s.io/api v0.20.2
k8s.io/apimachinery v0.20.2
)

replace github.com/olekukonko/tablewriter => github.com/cockroachdb/tablewriter v0.0.5-0.20200105123400-bd15540e8847
4 changes: 2 additions & 2 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cockroachdb/tablewriter v0.0.5-0.20200105123400-bd15540e8847 h1:c7yLgqcm/3c9lYtpWeVD9NYqA9cKsKHdpQM62PHtTUM=
github.com/cockroachdb/tablewriter v0.0.5-0.20200105123400-bd15540e8847/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
Expand Down Expand Up @@ -257,8 +259,6 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+
github.com/nsf/termbox-go v0.0.0-20201107200903-9b52a5faed9e h1:T8/SzSWIDoWV9trslLNfUdJ5yHrIXXuODEy5M0vou4U=
github.com/nsf/termbox-go v0.0.0-20201107200903-9b52a5faed9e/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
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=
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
2 changes: 1 addition & 1 deletion cli/run/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func choosePid(procs util.Processes) int {
{Name: "ID", Field: "id"},
{Name: "Pid", Field: "pid"},
{Name: "User", Field: "user"},
{Name: "Command", Field: "command"},
{Name: "Scoped", Field: "scoped"},
{Name: "Command", Field: "command"},
}, procs)
fmt.Println("Select an ID from the list:")
var selection string
Expand Down
6 changes: 3 additions & 3 deletions cli/util/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type Process struct {
ID int `json:"id"`
Pid int `json:"pid"`
User string `json:"user"`
Command string `json:"command"`
Scoped bool `json:"scoped"`
Command string `json:"command"`
}

// Processes is an array of Process
Expand Down Expand Up @@ -58,8 +58,8 @@ func ProcessesByName(name string) Processes {
ID: i,
Pid: pid,
User: PidUser(pid),
Command: PidCmdline(pid),
Scoped: PidScoped(pid),
Command: PidCmdline(pid),
})
i++
}
Expand Down Expand Up @@ -102,8 +102,8 @@ func ProcessesScoped() Processes {
ID: i,
Pid: pid,
User: PidUser(pid),
Command: PidCmdline(pid),
Scoped: scoped,
Command: PidCmdline(pid),
})
i++
}
Expand Down
2 changes: 2 additions & 0 deletions cli/util/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func printSlice(fields []ObjField, obj interface{}) error {
table.SetBorder(false)
table.SetTablePadding("\t")
table.SetNoWhiteSpace(true)
table.SetTrimWhiteSpaceAtEOL(true)
// table.SetHeaderColor(headerColors...)
table.SetBorder(false)
refval := GetValue(obj)
Expand All @@ -108,6 +109,7 @@ func printObj(fields []ObjField, obj interface{}) error {
table.SetColumnSeparator(" ")
table.SetCenterSeparator(" ")
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.SetTrimWhiteSpaceAtEOL(true)
// Iterate over fields
for _, field := range fields {
// Lookup field pointed to by Field
Expand Down

0 comments on commit 06988b7

Please sign in to comment.