diff --git a/table/table.go b/table/table.go index 3e9ad7f..51700f4 100644 --- a/table/table.go +++ b/table/table.go @@ -3,7 +3,6 @@ package table import ( "reflect" - "strings" "github.com/charmbracelet/bubbles/v2/help" "github.com/charmbracelet/bubbles/v2/key" @@ -424,22 +423,6 @@ func New(opts ...Option) *Model { return &m } -// FromValues create the table rows from a simple string. It uses `\n` by -// default for getting all the rows and the given separator for the fields on -// each row. -func (m *Model) FromValues(value, separator string) { - rows := [][]string{} - for _, line := range strings.Split(value, "\n") { - row := []string{} - for _, field := range strings.Split(line, separator) { - row = append(row, field) - } - rows = append(rows, row) - } - - m.SetRows(rows...) -} - // Bubble Tea Methods // Update is the Bubble Tea [tea.Model] update loop. diff --git a/table/table_test.go b/table/table_test.go index 49a84a1..9e98312 100644 --- a/table/table_test.go +++ b/table/table_test.go @@ -3,7 +3,6 @@ package table import ( "fmt" "image/color" - "reflect" "testing" "github.com/charmbracelet/lipgloss/v2" @@ -64,43 +63,6 @@ func TestNew(t *testing.T) { }) } -func TestFromValues(t *testing.T) { - input := "foo1,bar1\nfoo2,bar2\nfoo3,bar3" - table := New(WithHeaders("Foo", "Bar")) - table.FromValues(input, ",") - - if len(table.rows) != 3 { - t.Fatalf("expect table to have 3 rows but it has %d", len(table.rows)) - } - - expect := [][]string{ - {"foo1", "bar1"}, - {"foo2", "bar2"}, - {"foo3", "bar3"}, - } - if !reflect.DeepEqual(table.rows, expect) { - t.Fatal("table rows is not equals to the input") - } -} - -func TestFromValuesWithTabSeparator(t *testing.T) { - input := "foo1.\tbar1\nfoo,bar,baz\tbar,2" - table := New(WithHeaders("Foo", "Bar")) - table.FromValues(input, "\t") - - if len(table.rows) != 2 { - t.Fatalf("expect table to have 2 rows but it has %d", len(table.rows)) - } - - expect := [][]string{ - {"foo1.", "bar1"}, - {"foo,bar,baz", "bar,2"}, - } - if !reflect.DeepEqual(table.rows, expect) { - t.Fatal("table rows is not equals to the input") - } -} - func TestTableAlignment(t *testing.T) { headers := []string{ "Name",