tea.go
1package bubbletea
2
3import (
4 "smoothie/server/middleware"
5
6 tea "github.com/charmbracelet/bubbletea"
7 "github.com/gliderlabs/ssh"
8)
9
10func Middleware(bth func(ssh.Session) tea.Model, opts ...tea.ProgramOption) middleware.Middleware {
11 return func(sh ssh.Handler) ssh.Handler {
12 return func(s ssh.Session) {
13 m := bth(s)
14 if m != nil {
15 opts = append(opts, tea.WithInput(s), tea.WithOutput(s))
16 p := tea.NewProgram(m, opts...)
17 _ = p.Start()
18 }
19 sh(s)
20 }
21 }
22}