Skip to content
Myr

main.go

This file

Path

examples/vanish/main.go

36 lines · 596 bytes · Go

Last changed by

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

History of this file

Take it

1package main23import (4	"fmt"5	"os"67	tea "charm.land/bubbletea/v2"8)910type model bool1112func (m model) Init() tea.Cmd {13	return nil14}1516func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {17	if _, ok := msg.(tea.KeyPressMsg); ok {18		m = true19		return m, tea.Quit20	}21	return m, nil22}2324func (m model) View() tea.View {25	if m {26		return tea.NewView("")27	}28	return tea.NewView("Press any key to quit.\n(When this program quits, it will vanish without a trace.)")29}3031func main() {32	p := tea.NewProgram(model(false))33	if _, err := p.Run(); err != nil {34		fmt.Fprintln(os.Stderr, "Oh no:", err)35	}36}