program.go (738B)
1 package tui 2 3 import ( 4 "strings" 5 6 tea "github.com/charmbracelet/bubbletea" 7 "github.com/charmbracelet/lipgloss" 8 ssh "github.com/charmbracelet/ssh" 9 wish "github.com/charmbracelet/wish/bubbletea" 10 "github.com/muesli/termenv" 11 ) 12 13 func SSHHandler(sess ssh.Session) (tea.Model, []tea.ProgramOption) { 14 lipgloss.SetColorProfile(termenv.TrueColor) 15 model := newPortfolioModel(defaultUser(sess.User())) 16 opts := wish.MakeOptions(sess) 17 opts = append(opts, tea.WithAltScreen()) 18 return model, opts 19 } 20 21 func (m portfolioModel) Init() tea.Cmd { 22 return tea.Batch( 23 bootTickCmd(), 24 tickCmd(), 25 initWakaFooterCmd(), 26 ) 27 } 28 29 func defaultUser(user string) string { 30 user = strings.TrimSpace(user) 31 if user == "" { 32 return "visitor" 33 } 34 return user 35 }