Skip to content

Commit

Permalink
💡 chore: fix some code build error
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 22, 2022
1 parent a90c415 commit e23b2e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
18 changes: 10 additions & 8 deletions show/table/table.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package table

import (
"fmt"
"io"
"strings"

"github.com/gookit/gcli/v3/show"
"github.com/gookit/goutil/comdef"
"github.com/gookit/goutil/strutil"
)
Expand Down Expand Up @@ -35,8 +37,8 @@ type OpFunc func(opts *Options)

// Table a cli Table show
type Table struct {
Base // use for internal
out comdef.ByteStringWriter
show.Base // use for internal
out comdef.ByteStringWriter

// Title for the table
Title string
Expand All @@ -52,8 +54,8 @@ type Table struct {
colAlign map[int]strutil.PosFlag
}

// NewTable create table
func NewTable(title string, fns ...OpFunc) *Table {
// New create table
func New(title string, fns ...OpFunc) *Table {
t := &Table{
Title: title,
opts: &Options{
Expand Down Expand Up @@ -108,7 +110,7 @@ func (t *Table) SetRows(rs any) *Table {
// String format as string
func (t *Table) String() string {
t.Format()
return t.buf.String()
return t.Buffer().String()
}

// Print formatted message
Expand Down Expand Up @@ -172,8 +174,8 @@ func (t *Table) formatHeader() {

// Format as string
func (t *Table) formatBody() {
for i, row := range t.Rows {

for _, row := range t.Rows {
fmt.Println(row)
}

panic("implement me")
Expand All @@ -187,7 +189,7 @@ func (t *Table) formatFooter() {
// WriteTo format table to string and write to w.
func (t *Table) WriteTo(w io.Writer) (int64, error) {
t.Format()
return t.buf.WriteTo(w)
return t.Buffer().WriteTo(w)
}

// Row represents a row in a table
Expand Down
8 changes: 5 additions & 3 deletions show/table/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package table_test
import (
"testing"

"github.com/gookit/gcli/v3/show"
"github.com/gookit/gcli/v3/show/table"
)

func TestNewTable(t *testing.T) {
tb := show.NewTable("Table example1")
tb.SetRows()
tb := table.New("Table example1")
tb.SetRows([]any{
// TODO ...
})

tb.Println()
}

0 comments on commit e23b2e6

Please sign in to comment.