Skip to content

Commit

Permalink
Replace olekukonko/tablewriter with amterp/go-tbl
Browse files Browse the repository at this point in the history
I was working on colored headers and noticed a bug which made them not
line up properly with the rows below. This seems like a tablewriter bug
but this library is not actively maintained.

I foresee a few of these things will pop up. rad will depend quite
heavily on its table writing library so I think we should just take the
step to fork the original now so I can make the modifications I want.
  • Loading branch information
amterp committed Sep 20, 2024
1 parent e6e5a22 commit 4d58183
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions core/tbl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core

import (
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/amterp/go-tbl"
"github.com/samber/lo"
"golang.org/x/term"
"io"
Expand All @@ -26,7 +26,7 @@ type ColumnSort struct {

type TblWriter struct {
writer io.Writer
tbl *tablewriter.Table
tbl *tblwriter.Table
headers []string
rows [][]string
sorting []ColumnSort
Expand All @@ -37,7 +37,7 @@ func NewTblWriter() *TblWriter {
stdWriter := RP.GetStdWriter()
return &TblWriter{
writer: stdWriter,
tbl: tablewriter.NewWriter(stdWriter),
tbl: tblwriter.NewWriter(stdWriter),
numColumns: 0,
}
}
Expand Down Expand Up @@ -147,8 +147,8 @@ func (w *TblWriter) Render() {

w.tbl.SetAutoWrapText(false)
w.tbl.SetAutoFormatHeaders(true)
w.tbl.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
w.tbl.SetAlignment(tablewriter.ALIGN_LEFT)
w.tbl.SetHeaderAlignment(tblwriter.ALIGN_LEFT)
w.tbl.SetAlignment(tblwriter.ALIGN_LEFT)
w.tbl.SetCenterSeparator("")
w.tbl.SetColumnSeparator("")
w.tbl.SetRowSeparator("")
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ module rad
go 1.22

require (
github.com/olekukonko/tablewriter v0.0.5
github.com/amterp/go-tbl v0.3.0
github.com/samber/lo v1.47.0
github.com/scylladb/go-set v1.0.2
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
golang.org/x/term v0.24.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-runewidth v0.0.10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/rivo/uniseg v0.1.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
github.com/amterp/go-tbl v0.3.0 h1:p+9wGuSJmMQYJ58QgtBUHnUWdKS0eEHVIkwMEMLwRIQ=
github.com/amterp/go-tbl v0.3.0/go.mod h1:DYsdVp1O4xwiP0/RauP/TObEse15Q2UAdVWm1rFCvwg=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/set v0.2.1 h1:nn2CaJyknWE/6txyUDGwysr3G5QC6xWB/PtVjPBbeaA=
github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
Expand Down

0 comments on commit 4d58183

Please sign in to comment.