Replies: 1 comment 1 reply
-
Hi there! It looks like you're generally on the right track. When you send a Here's a working example: package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
)
type model struct {
quitting bool
}
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(type) {
case tea.KeyMsg:
// Tell the model we're quitting. We'll get one final render before we exit.
m.quitting = true
return m, tea.Quit
}
return m, nil
}
func (m model) View() string {
if m.quitting {
// Say goodbye! This is the final render.
return "Bye!!\n"
}
return "Press any key to quit"
}
func main() {
if err := tea.NewProgram(model{}).Start(); err != nil {
fmt.Println("uh oh", err)
os.Exit(1)
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Love the project. Thank you!
I have a utility that runs some tasks and then exits. I'm looking for a mechanism to perform the last render before stopping.
I've noted that calling
p.Quit()
will exit before the last render.Ideally, I wouldn't have to rely on the ticker to perform the quit. It's also weird to "start" via the program but "stop" via the model.
Beta Was this translation helpful? Give feedback.
All reactions