From 061e464a70185b499650ec42583b132d8120b382 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 4 Feb 2025 13:01:13 -0500 Subject: [PATCH] refactor!: restore bubbletea model interface --- filepicker/filepicker.go | 4 ++-- go.mod | 2 +- go.sum | 2 ++ progress/progress.go | 4 ++-- stopwatch/stopwatch.go | 4 ++-- timer/timer.go | 4 ++-- viewport/viewport.go | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/filepicker/filepicker.go b/filepicker/filepicker.go index 4b6f5ac..86aaad0 100644 --- a/filepicker/filepicker.go +++ b/filepicker/filepicker.go @@ -233,8 +233,8 @@ func (m Model) Height() int { } // Init initializes the file picker model. -func (m Model) Init() (Model, tea.Cmd) { - return m, m.readDir(m.CurrentDirectory, m.ShowHidden) +func (m Model) Init() tea.Cmd { + return m.readDir(m.CurrentDirectory, m.ShowHidden) } // Update handles user interactions within the file picker model. diff --git a/go.mod b/go.mod index 43f6df2..aa3c9a0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/MakeNowJust/heredoc v1.0.0 github.com/atotto/clipboard v0.1.4 - github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250203222705-2e91ec2235cd + github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250204175057-2a96bc438da6 github.com/charmbracelet/harmonica v0.2.0 github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20250204145343-96725424379d github.com/charmbracelet/x/ansi v0.8.0 diff --git a/go.sum b/go.sum index 27bba77..07c1497 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250203222705-2e91ec2235cd h1:u+kqgSbIL4pnP7huv4kaYUCmuN2L4yyDvdH81QJ4FZ0= github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250203222705-2e91ec2235cd/go.mod h1:zaWGYfO6cBtu4dRgGbVN7yMYUz3j9sVIzHy2gn0jdo8= +github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250204175057-2a96bc438da6 h1:KbLqbYgHC5JZWks50WjBJr92Hs+GpiauwZaDObw9vxE= +github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250204175057-2a96bc438da6/go.mod h1:zaWGYfO6cBtu4dRgGbVN7yMYUz3j9sVIzHy2gn0jdo8= github.com/charmbracelet/colorprofile v0.2.0 h1:iiIQlp3LSvoJPtR11KoDfIf9wqWm2mn/iU420rHOZ/A= github.com/charmbracelet/colorprofile v0.2.0/go.mod h1:6wPrSSR4QtwYtOY3h0bLRw5YOUAIKWlZIJ02CTAsZsk= github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ= diff --git a/progress/progress.go b/progress/progress.go index 512aaa8..10aa9f0 100644 --- a/progress/progress.go +++ b/progress/progress.go @@ -182,8 +182,8 @@ func New(opts ...Option) Model { } // Init exists to satisfy the tea.Model interface. -func (m Model) Init() (Model, tea.Cmd) { - return m, nil +func (m Model) Init() tea.Cmd { + return nil } // Update is used to animate the progress bar during transitions. Use diff --git a/stopwatch/stopwatch.go b/stopwatch/stopwatch.go index 3c79a91..89f36d2 100644 --- a/stopwatch/stopwatch.go +++ b/stopwatch/stopwatch.go @@ -80,8 +80,8 @@ func (m Model) ID() int { } // Init starts the stopwatch. -func (m Model) Init() (Model, tea.Cmd) { - return m, m.Start() +func (m Model) Init() tea.Cmd { + return m.Start() } // Start starts the stopwatch. diff --git a/timer/timer.go b/timer/timer.go index 22c13ae..c8e3bf3 100644 --- a/timer/timer.go +++ b/timer/timer.go @@ -134,8 +134,8 @@ func (m Model) Timedout() bool { } // Init starts the timer. -func (m Model) Init() (Model, tea.Cmd) { - return m, m.tick() +func (m Model) Init() tea.Cmd { + return m.tick() } // Update handles the timer tick. diff --git a/viewport/viewport.go b/viewport/viewport.go index 5e6c68e..8ac13ea 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -145,8 +145,8 @@ func (m *Model) setInitialValues() { } // Init exists to satisfy the tea.Model interface for composability purposes. -func (m Model) Init() (Model, tea.Cmd) { - return m, nil +func (m Model) Init() tea.Cmd { + return nil } // Height returns the height of the viewport.