Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,10 @@ func InspectDatabase(db ctxcdb.Database, keyPrefix, keyStart []byte) error {
total.Add(uint64(ancient.size()))
}

table := newTableWriter(os.Stdout)
table.Header([]string{"Database", "Category", "Size", "Items"})
table.Footer([]string{"", "Total", common.StorageSize(total.Load()).String(), " "})
table.Append(stats)
table := NewTableWriter(os.Stdout)
table.SetHeader([]string{"Database", "Category", "Size", "Items"})
table.SetFooter([]string{"", "Total", common.StorageSize(total.Load()).String(), fmt.Sprintf("%d", count.Load())})
table.AppendBulk(stats)
table.Render()

if !unaccounted.empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// TODO: naive stub implementation for tablewriter

//go:build tinygo
// +build tinygo
// Naive stub implementation for tablewriter

package rawdb

Expand All @@ -40,7 +37,7 @@ type Table struct {
rows [][]string
}

func newTableWriter(w io.Writer) *Table {
func NewTableWriter(w io.Writer) *Table {
return &Table{out: w}
}

Expand Down Expand Up @@ -89,6 +86,7 @@ func (t *Table) render() error {
rowSeparator := t.buildRowSeparator(widths)

if len(t.headers) > 0 {
fmt.Fprintln(t.out, rowSeparator)
t.printRow(t.headers, widths)
fmt.Fprintln(t.out, rowSeparator)
}
Expand All @@ -100,6 +98,7 @@ func (t *Table) render() error {
if len(t.footer) > 0 {
fmt.Fprintln(t.out, rowSeparator)
t.printRow(t.footer, widths)
fmt.Fprintln(t.out, rowSeparator)
}

return nil
Expand Down Expand Up @@ -172,21 +171,22 @@ func (t *Table) calculateColumnWidths() []int {
//
// It generates a string with dashes (-) for each column width, joined by plus signs (+).
//
// Example output: "----------+--------+-----------"
// Example output: "+----------+--------+-----------+"
func (t *Table) buildRowSeparator(widths []int) string {
parts := make([]string, len(widths))
for i, w := range widths {
parts[i] = strings.Repeat("-", w)
}
return strings.Join(parts, "+")
return "+" + strings.Join(parts, "+") + "+"
}

// printRow outputs a single row to the table writer.
//
// Each cell is padded with spaces and separated by pipe characters (|).
//
// Example output: " Database | Size | Items "
// Example output: "| Database | Size | Items |"
func (t *Table) printRow(row []string, widths []int) {
fmt.Fprintf(t.out, "|")
for i, cell := range row {
if i > 0 {
fmt.Fprint(t.out, "|")
Expand All @@ -204,5 +204,6 @@ func (t *Table) printRow(row []string, widths []int) {

fmt.Fprintf(t.out, "%s%s%s", leftPadding, cell, rightPadding)
}
fmt.Fprintf(t.out, "|")
fmt.Fprintln(t.out)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//go:build tinygo
// +build tinygo

package rawdb

import (
Expand All @@ -27,7 +24,7 @@ import (

func TestTableWriterTinyGo(t *testing.T) {
var buf bytes.Buffer
table := newTableWriter(&buf)
table := NewTableWriter(&buf)

headers := []string{"Database", "Size", "Items", "Status"}
rows := [][]string{
Expand All @@ -51,7 +48,7 @@ func TestTableWriterValidationErrors(t *testing.T) {
// Test missing headers
t.Run("MissingHeaders", func(t *testing.T) {
var buf bytes.Buffer
table := newTableWriter(&buf)
table := NewTableWriter(&buf)

rows := [][]string{{"x", "y", "z"}}

Expand All @@ -66,7 +63,7 @@ func TestTableWriterValidationErrors(t *testing.T) {

t.Run("NotEnoughRowColumns", func(t *testing.T) {
var buf bytes.Buffer
table := newTableWriter(&buf)
table := NewTableWriter(&buf)

headers := []string{"A", "B", "C"}
badRows := [][]string{
Expand All @@ -85,7 +82,7 @@ func TestTableWriterValidationErrors(t *testing.T) {

t.Run("TooManyRowColumns", func(t *testing.T) {
var buf bytes.Buffer
table := newTableWriter(&buf)
table := NewTableWriter(&buf)

headers := []string{"A", "B", "C"}
badRows := [][]string{
Expand All @@ -105,7 +102,7 @@ func TestTableWriterValidationErrors(t *testing.T) {
// Test mismatched footer columns
t.Run("MismatchedFooterColumns", func(t *testing.T) {
var buf bytes.Buffer
table := newTableWriter(&buf)
table := NewTableWriter(&buf)

headers := []string{"A", "B", "C"}
rows := [][]string{{"x", "y", "z"}}
Expand Down
33 changes: 0 additions & 33 deletions core/rawdb/database_tablewriter_unix.go

This file was deleted.

5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ require (
github.com/muesli/reflow v0.3.0
github.com/muesli/termenv v0.16.0
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
github.com/olekukonko/tablewriter v1.1.0
github.com/peterh/liner v1.2.2
github.com/pion/stun/v2 v2.0.0
github.com/rs/cors v1.11.1
Expand Down Expand Up @@ -152,7 +151,6 @@ require (
github.com/elliotchance/orderedmap v1.8.0 // indirect
github.com/emicklei/dot v1.9.2 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
github.com/getsentry/sentry-go v0.36.2 // indirect
github.com/go-llsqlite/adapter v0.2.0 // indirect
Expand Down Expand Up @@ -191,9 +189,6 @@ require (
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/nutsdb/nutsdb v1.0.4 // indirect
github.com/oapi-codegen/runtime v1.1.2 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
github.com/olekukonko/errors v1.1.0 // indirect
github.com/olekukonko/ll v0.1.2 // indirect
github.com/otiai10/copy v1.14.1 // indirect
github.com/otiai10/mint v1.6.3 // indirect
github.com/pion/datachannel v1.5.10 // indirect
Expand Down
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,6 @@ github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab/go.mod h1
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/ferranbt/fastssz v1.0.0 h1:9EXXYsracSqQRBQiHeaVsG/KQeYblPf40hsQPb9Dzk8=
github.com/ferranbt/fastssz v1.0.0/go.mod h1:Ea3+oeoRGGLGm5shYAeDgu6PGUlcvQhE2fILyD9+tGg=
github.com/fjl/gencodec v0.1.0 h1:B3K0xPfc52cw52BBgUbSPxYo+HlLfAgWMVKRWXUXBcs=
Expand Down Expand Up @@ -907,17 +905,9 @@ github.com/oapi-codegen/runtime v1.1.2/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS
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/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc=
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0=
github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM=
github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
github.com/olekukonko/ll v0.1.2 h1:lkg/k/9mlsy0SxO5aC+WEpbdT5K83ddnNhAepz7TQc0=
github.com/olekukonko/ll v0.1.2/go.mod h1:b52bVQRRPObe+yyBl0TxNfhesL0nedD4Cht0/zx55Ew=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/olekukonko/tablewriter v0.0.5-0.20200416053754-163badb3bac6/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/olekukonko/tablewriter v1.1.0 h1:N0LHrshF4T39KvI96fn6GT8HEjXRXYNDrDjKFDB7RIY=
github.com/olekukonko/tablewriter v1.1.0/go.mod h1:5c+EBPeSqvXnLLgkm9isDdzR3wjfBkHR9Nhfp3NWrzo=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
20 changes: 0 additions & 20 deletions vendor/github.com/fatih/color/LICENSE.md

This file was deleted.

Loading
Loading