Update tutorials per new Model interface-based structure
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Christian Rocha · committed by Christian Rocha · parent c72ee75 · Browse files · 7 files·+203 added−183 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+203 added−183 removed
- other:+203 added−183 removed
Provenance
- Commit
9c5d426- Tree
68774cd- Author
Christian Rocha <christian@rocha.is>- Committer
Christian Rocha <christian@rocha.is>- Parent
c72ee75
7 files changed+203 added−183 removed
modified:tutorials/basics/main.go+9 added-11 removed
11 unmodified lines12 choices []string13 selected map[int]struct{}14 }15 16-func initialize() (tea.Model, tea.Cmd) {17- return model{18- choices: []string{"Carrots", "Celery", "Kohlrabi"},19- selected: make(map[int]struct{}),16+var initialModel = model{17+ choices: []string{"Carrots", "Celery", "Kohlrabi"},18+ selected: make(map[int]struct{}),20- }, nil19 }20 23-func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {24- m, _ := mdl.(model)21+func (m model) Init() tea.Cmd {22+ return nil23+}24 25+func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {26 switch msg := msg.(type) {27 case tea.KeyMsg:28 switch msg.String() {29 case "ctrl+c", "q":18 unmodified lines48 49 return m, nil50 }51 52-func view(mdl tea.Model) string {53- m, _ := mdl.(model)54-52+func (m model) View() string {53 s := "What should we buy at the market?\n\n"54 55 for i, choice := range m.choices {56 cursor := " "14 unmodified lines71 return s72 }73 74 func main() {77- p := tea.NewProgram(initialize, update, view)75+ p := tea.NewProgram(initialModel)76 if err := p.Start(); err != nil {77 fmt.Printf("Alas, there's been an error: %v", err)78 os.Exit(1)79 }1 unmodified linemodified:tutorials/basics/README.md+29 added-36 removed
1 Bubble Tea Basics2 =================3 4 Bubble Tea is based on the functional design paradigms of [The Elm5-Architecture][elm]. It might not seem very Go-like at first, but once you get6-used to the general structure you'll find that most of the idomatic Go things7-you know and love are still relevant and useful here.5+Architecture][elm] which happens work nicely with Go.6 7 By the way, the non-annotated source code for this program is available8 [on GitHub](https://github.com/charmbracelet/bubbletea/tree/master/tutorials/basics).9 19 unmodified lines29 )30 ```31 32 Bubble Tea programs are comprised of a **model** that describes the application35-state and three simple functions that are centered around that model:33+state and three simple methods on that model:34 37-* **Initialize**, a function that returns the model's initial state.35+* **Init**, a function that returns an initial command for the application to run.36 * **Update**, a function that handles incoming events and updates the model accordingly.37 * **View**, a function that renders the UI based on the data in the model.38 39 ## The Model8 unmodified lines48 selected map[int]struct{} // which to-do items are selected49 }50 ```51 54-## The Initialization Function52+## Initialization53 56-Next we'll define a function that will initialize our application. An57-initialize function returns a model representing our application's initial58-state, as well as a `Cmd` that could perform some initial I/O. For now, we59-don't need to do any I/O, so for the command we'll just return `nil`, which60-translates to "no command."54+Next we'll define our application’s initial state. We’ll store our initial55+model in a simple variable, and then define the `Init` method. `Init` can56+return a `Cmd` that could perform some initial I/O. For now, we don't need to57+do any I/O, so for the command we'll just return `nil`, which translates to "no58+command."59 60 ```go63- func initialize() (tea.Model, tea.Cmd) {64- m := model{61+ var initialModel = model{62+ // Our to-do list is just a grocery list63+ choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},64 66- // Our to-do list is just a grocery list67- choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},65+ // A map which indicates which choices are selected. We're using66+ // the map like a mathematical set. The keys refer to the indexes67+ // of the `choices` slice, above.68+ selected: make(map[int]struct{}),69+ }70 69- // A map which indicates which choices are selected. We're using70- // the map like a mathematical set. The keys refer to the indexes71- // of the `choices` slice, above.72- selected: make(map[int]struct{}),73- }74-75- // Return the model and `nil`, which means "no I/O right now, please."71+ func (m model) Init() (tea.Cmd) {72+ // Just return `nil`, which means "no I/O right now, please."73 return m, nil74 }75 ```76 80-## The Update Function77+## The Update Method78 82-Next we'll define the update function. The update function is called when79+Next we'll define the update method. The update function is called when80 "things happen." Its job is to look at what has happened and return an updated81 model in response to whatever happened. It can also return a `Cmd` and make82 more things happen, but for now don't worry about that part.83 10 unmodified lines94 For now, we'll just deal with `tea.KeyMsg` messages, which are automatically95 sent to the update function when keys are pressed.96 97 ```go101- func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {102- m, _ := mdl.(model)103-98+ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {99 switch msg := msg.(type) {100 101 // Is it a key press?102 case tea.KeyMsg:38 unmodified lines141 You may have noticed that "ctrl+c" and "q" above return a `tea.Quit` command142 with the model. That's a special command which instructs the Bubble Tea runtime143 to quit, exiting the program.144 150-## The View Function145+## The View Method146 152-At last, it's time to render our UI. Of all the functions, the view is the153-simplest. A model, in it's current state, comes in and a `string` comes out.154-That string is our UI!147+At last, it's time to render our UI. Of all the methods, the view is the148+simplest. We look at the model in it's current state and use it to return149+a `string`. That string is our UI!150 151 Because the view describes the entire UI of your application, you don't have152 to worry about redraw logic and stuff like that. Bubble Tea takes care of it153 for you.154 155 ```go161- func view(mdl tea.Model) string {162- m, _ := mdl.(model)163-156+ func (m model) View() string {157 // The header158 s := "What should we buy at the market?\n\n"159 160 // Iterate over our choices24 unmodified lines185 ```186 187 ## All Together Now188 196-The last step is to simply run our program. We pass our functions to189+The last step is to simply run our program. We pass our initial model to190 `tea.NewProgram` and let it rip:191 192 ```go193 func main() {201- p := tea.NewProgram(initialize, update, view)194+ p := tea.NewProgram(initialModel)195 if err := p.Start(); err != nil {196 fmt.Printf("Alas, there's been an error: %v", err)197 os.Exit(1)198 }41 unmodified linesmodified:tutorials/commands/main.go+5 added-9 removed
31 unmodified lines32 // For messages that contain errors it's often handy to also implement the33 // error interface on the message.34 func (e errMsg) Error() string { return e.err.Error() }35 36-func initialize() (tea.Model, tea.Cmd) {37- return model{}, checkServer36+func (m model) Init() tea.Cmd {37+ return checkServer38 }39 40-func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {41- m, _ := mdl.(model)42-40+func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {41 switch msg := msg.(type) {42 43 case statusMsg:44 m.status = int(msg)11 unmodified lines56 57 return m, nil58 }59 62-func view(mdl tea.Model) string {63- m, _ := mdl.(model)64-60+func (m model) View() string {61 if m.err != nil {62 return fmt.Sprintf("\nWe had some trouble: %v\n\n", m.err)63 }64 4 unmodified lines69 return "\n" + s + "\n\n"70 }71 72 func main() {77- if err := tea.NewProgram(initialize, update, view).Start(); err != nil {73+ if err := tea.NewProgram(model{}).Start(); err != nil {74 fmt.Printf("Uh oh, there was an error: %v\n", err)75 os.Exit(1)76 }77 }modified:tutorials/commands/README.md+13 added-15 removed
83 unmodified lines84 And notice that we've defined two new `Msg` types. They can be any type, even85 an empty struct. We'll come back to them later later in our update function.86 First, let's write our initialization function.87 88-## The Initialization Function88+## The Initialization Method89 90-The initilization function is very simple. We return an empty model and the91-the `Cmd` we made earlier. Note that we don't call the function; the Bubble Tea92-runtime will do that when the time is right.90+The initilization method is very simple: we return the `Cmd` we made earlier.91+Note that we don't call the function; the Bubble Tea runtime will do that when92+the time is right.93 94 ```go95-func initialize() (tea.Model, tea.Cmd) {96- return model{}, checkServer95+func (m model) Init() (tea.Cmd) {96+ return checkServer97 }98 ```99 100-## The Update Function100+## The Update Method101 102 Internally, `Cmd`s run asynchronously in a goroutine. The `Msg` they return is103 collected and sent to our update function for handling. Remember those message104 types we made earlier when we were making the `checkServer` command? We handle105 them here. This makes dealing with many asynchronous operations very easy.106 107 ```go108-func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {109- m, _ := mdl.(model)110-108+func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {109 switch msg := msg.(type) {110 111 case statusMsg:112 // The server returned a status message. Save it to our model. Also28 unmodified lines141 Our view is very straightforward. We look at the current model and build a142 string accordingly:143 144 ```go147-func view(mdl tea.Model) string {148- m, _ := mdl.(model)149-145+func (m model) View() string {146 // If there's an error, print it out and don't do anything else.147 if m.err != nil {148 return fmt.Sprintf("\nWe had some trouble: %v\n\n", m.err)149 }12 unmodified lines162 ```163 164 ## Run the program165 170-The only thing left to do is run the program, so let's do that!166+The only thing left to do is run the program, so let's do that! Our initial167+model doesn't need any data at all in this case, we just initialize it with168+as a `struct` with defaults.169 170 ```go171 func main() {174- if err := tea.NewProgram(initialize, update, view).Start(); err != nil {172+ if err := tea.NewProgram(model{}).Start(); err != nil {173 fmt.Printf("Uh oh, there was an error: %v\n", err)174 os.Exit(1)175 }176 }66 unmodified linesmodified:tutorials/go.mod+1 added-1 removed
1 module tutorial2 3 go 1.144 5-require github.com/charmbracelet/bubbletea v0.10.35+require github.com/charmbracelet/bubbletea v0.11.16 7 replace github.com/charmbracelet/bubbletea => ../modified:tutorials/go.sum+9 added-6 removed
1+github.com/containerd/console v1.0.1 h1:u7SFAJyRqWcG6ogaMAx3KjSTy1e3hT9QxqX7Jco7dRc=2+github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw=3 github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f h1:5CjVwnuUcp5adK4gmY6i72gpVFVnZDP2h5TmPScB6u4=4 github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=5 github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=6 github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=2 unmodified lines9 github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=10 github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=11 github.com/muesli/termenv v0.7.2 h1:r1raklL3uKE7rOvWgSenmEm2px+dnc33OTisZ8YR1fw=12 github.com/muesli/termenv v0.7.2/go.mod h1:ct2L5N2lmix82RaY3bMWwVu/jUFc9Ule0KGDCiKYPh8=11-github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03 h1:pd4YKIqCB0U7O2I4gWHgEUA2mCEOENmco0l/bM957bU=12-github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03/go.mod h1:Z9+Ul5bCbBKnbCvdOWbLqTHhJiYV414CURZJba6L8qA=13+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=14+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=15 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=14-golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg=15-golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=16+golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee h1:4yd7jl+vXjalO5ztz6Vc1VADv+S/80LGJmyl1ROJ2AI=17+golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=18 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=19 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=20 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=21 golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=20-golang.org/x/sys v0.0.0-20200821140526-fda516888d29 h1:mNuhGagCf3lDDm5C0376C/sxh6V7fy9WbdEu/YDNA04=21-golang.org/x/sys v0.0.0-20200821140526-fda516888d29/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=22+golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=23+golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 h1:bNEHhJCnrwMKNMmOx3yAynp5vs5/gRy+XWFtZFu7NBM=24+golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=25 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=modified:README.md+137 added-105 removed
37 unmodified lines38 39 ## Tutorial40 41 Bubble Tea is based on the functional design paradigms of [The Elm42-Architecture][elm]. It might not seem very Go-like at first, but once you get43-used to the general structure you'll find that most of the idomatic Go things44-you know and love are still relevant and useful here.42+Architecture][elm] which happens work nicely with Go.43 46-By the way, the non-annotated source code for this program47-[is also available](https://github.com/charmbracelet/bubbletea/tree/master/tutorials/basics).44+By the way, the non-annotated source code for this program is available45+[on GitHub](https://github.com/charmbracelet/bubbletea/tree/master/tutorials/basics).46 47 This tutorial assumes you have a working knowledge of Go.48 49 [elm]: https://guide.elm-lang.org/architecture/50 53-### Enough! Let's get to it.51+## Enough! Let's get to it.52 53 For this tutorial we're making a to-do list.54 57-We'll start by defining our package and import some libraries. Our only external55+To start we'll define our package and import some libraries. Our only external56 import will be the Bubble Tea library, which we'll call `tea` for short.57 58 ```go61-package main59+ package main60 63-import (64- "fmt"65- "os"61+ import (62+ "fmt"63+ "os"64 67- tea "github.com/charmbracelet/bubbletea"68-)65+ tea "github.com/charmbracelet/bubbletea"66+ )67 ```68 69 Bubble Tea programs are comprised of a **model** that describes the application72-state and three simple functions that are centered around that model:70+state and three simple methods on that model:71 74-* **Initialize**, a function that returns the model's initial state.72+* **Init**, a function that returns an initial command for the application to run.73 * **Update**, a function that handles incoming events and updates the model accordingly.74 * **View**, a function that renders the UI based on the data in the model.75 78-### The Model76+## The Model77 78 So let's start by defining our model which will store our application's state.79 It can be any type, but a `struct` usually makes the most sense.80 81 ```go84-type model struct {85- choices []string // items on the to-do list86- cursor int // which to-do list item our cursor is pointing at87- selected map[int]struct{} // which to-do items are selected88-}82+ type model struct {83+ choices []string // items on the to-do list84+ cursor int // which to-do list item our cursor is pointing at85+ selected map[int]struct{} // which to-do items are selected86+ }87 ```88 91-### The Initialization Function89+## Initialization90 93-Next we'll define a function that will initialize our application. An94-initialize function returns a model representing our application's initial95-state, as well as a `Cmd` that could perform some initial I/O. For now, we96-don't need to do any I/O, so for the command we'll just return `nil`, which97-translates to "no command."91+Next we'll define our application’s initial state. We’ll store our initial92+model in a simple variable, and then define the `Init` method. `Init` can93+return a `Cmd` that could perform some initial I/O. For now, we don't need to94+do any I/O, so for the command we'll just return `nil`, which translates to "no95+command."96 97 ```go100-func initialize() (tea.Model, tea.Cmd) {101- m := model{102-98+ var initialModel = model{99 // Our to-do list is just a grocery list100 choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},101 102 // A map which indicates which choices are selected. We're using1 unmodified line104 // of the `choices` slice, above.105 selected: make(map[int]struct{}),106 }107 108+ func (m model) Init() (tea.Cmd) {112- // Return the model and `nil`, which means "no I/O right now, please."113- return m, nil114-}109+ // Just return `nil`, which means "no I/O right now, please."110+ return m, nil111+ }112 ```113 117-### The Update Function114+## The Update Method115 119-Next we'll define the update function. The update function is called when116+Next we'll define the update method. The update function is called when117 "things happen." Its job is to look at what has happened and return an updated118 model in response to whatever happened. It can also return a `Cmd` and make119 more things happen, but for now don't worry about that part.120 10 unmodified lines131 For now, we'll just deal with `tea.KeyMsg` messages, which are automatically132 sent to the update function when keys are pressed.133 134 ```go138-func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {139- m, _ := mdl.(model)135+ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {136+ switch msg := msg.(type) {137 141- switch msg := msg.(type) {138+ // Is it a key press?139+ case tea.KeyMsg:140 143- // Is it a key press?144- case tea.KeyMsg:141+ // Cool, what was the actual key pressed?142+ switch msg.String() {143 146- // Cool, what was the actual key pressed?147- switch msg.String() {144+ // These keys should exit the program.145+ case "ctrl+c", "q":146+ return m, tea.Quit147 149- // These keys should exit the program.150- case "ctrl+c", "q":151- return m, tea.Quit148+ // The "up" and "k" keys move the cursor up149+ case "up", "k":150+ if m.cursor > 0 {151+ m.cursor--152+ }153 153- // The "up" and "k" keys move the cursor up154- case "up", "k":155- if m.cursor > 0 {156- m.cursor--157- }154+ // The "down" and "j" keys move the cursor down155+ case "down", "j":156+ if m.cursor < len(m.choices)-1 {157+ m.cursor++158+ }159 159- // The "down" and "j" keys move the cursor down160- case "down", "j":161- if m.cursor < len(m.choices)-1 {162- m.cursor++160+ // The "enter" key and the spacebar (a literal space) toggle161+ // the selected state for the item that the cursor is pointing at.162+ case "enter", " ":163+ _, ok := m.selected[m.cursor]164+ if ok {165+ delete(m.selected, m.cursor)166+ } else {167+ m.selected[m.cursor] = struct{}{}168+ }169 }164-165- // The "enter" key and the spacebar (a literal space) toggle166- // the selected state for the item that the cursor is pointing at.167- case "enter", " ":168- _, ok := m.selected[m.cursor]169- if ok {170- delete(m.selected, m.cursor)171- } else {172- m.selected[m.cursor] = struct{}{}173- }170 }175- }171 177- // Return the updated model to the Bubble Tea runtime for processing.178- // Note that we're not returning a command.179- return m, nil180-}172+ // Return the updated model to the Bubble Tea runtime for processing.173+ // Note that we're not returning a command.174+ return m, nil175+ }176 ```177 178 You may have noticed that "ctrl+c" and "q" above return a `tea.Quit` command179 with the model. That's a special command which instructs the Bubble Tea runtime180 to quit, exiting the program.181 187-### The View Function182+## The View Method183 189-At last, it's time to render our UI. Of all the functions, the view is the190-simplest. A model, in it's current state, comes in and a `string` comes out.191-That string is our UI!184+At last, it's time to render our UI. Of all the methods, the view is the185+simplest. We look at the model in it's current state and use it to return186+a `string`. That string is our UI!187 188 Because the view describes the entire UI of your application, you don't have189 to worry about redraw logic and stuff like that. Bubble Tea takes care of it190 for you.191 192 ```go198-func view(mdl tea.Model) string {199- m, _ := mdl.(model)193+ func (m model) View() string {194+ // The header195+ s := "What should we buy at the market?\n\n"196 201- // The header202- s := "What should we buy at the market?\n\n"197+ // Iterate over our choices198+ for i, choice := range m.choices {199 204- // Iterate over our choices205- for i, choice := range m.choices {200+ // Is the cursor pointing at this choice?201+ cursor := " " // no cursor202+ if m.cursor == i {203+ cursor = ">" // cursor!204+ }205 207- // Is the cursor pointing at this choice?208- cursor := " " // no cursor209- if m.cursor == i {210- cursor = ">" // cursor!211- }206+ // Is this choice selected?207+ checked := " " // not selected208+ if _, ok := m.selected[i]; ok {209+ checked = "x" // selected!210+ }211 213- // Is this choice selected?214- checked := " " // not selected215- if _, ok := m.selected[i]; ok {216- checked = "x" // selected!212+ // Render the row213+ s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice)214 }215 219- // Render the row220- s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice)221- }216+ // The footer217+ s += "\nPress q to quit.\n"218 223- // The footer224- s += "\nPress q to quit.\n"225-226- // Send the UI for rendering227- return s228-}219+ // Send the UI for rendering220+ return s221+ }222 ```223 231-### All Together Now224+## All Together Now225 233-The last step is to simply run our program. We pass our functions to226+The last step is to simply run our program. We pass our initial model to227 `tea.NewProgram` and let it rip:228 229 ```go237-func main() {238- p := tea.NewProgram(initialize, update, view)239- if err := p.Start(); err != nil {240- fmt.Printf("Alas, there's been an error: %v", err)241- os.Exit(1)230+ func main() {231+ p := tea.NewProgram(initialModel)232+ if err := p.Start(); err != nil {233+ fmt.Printf("Alas, there's been an error: %v", err)234+ os.Exit(1)235+ }236 }243-}237 ```238 239+## What's Next?240+241+This tutorial covers the basics of building an interactive terminal UI, but242+in the real world you'll also need to perform I/O. To learn about that have a243+look at the [Command Tutorial][cmd]. It's pretty simple.244+245+There are also several [Bubble Tea examples][examples] available and, of course,246+there are [Go Docs][docs].247+248+[cmd]: http://github.com/charmbracelet/bubbletea/tree/master/tutorials/commands/249+[examples]: http://github.com/charmbracelet/bubbletea/tree/master/examples250+[docs]: https://pkg.go.dev/github.com/charmbracelet/glow?tab=doc251+252+### Bubble Tea in the Wild253+254+For some Bubble Tea programs in production, see:255+256+* [Glow](https://github.com/charmbracelet/glow): a markdown reader, browser and online markdown stash257+* [The Charm Tool](https://github.com/charmbracelet/charm): the Charm user account manager258+259+### Libraries we use with Bubble Tea260+261+* [Bubbles][bubbles] various Bubble Tea components262+* [Termenv][termenv]: Advanced ANSI styling for terminal applications263+* [Reflow][reflow]: ANSI-aware methods for reflowing blocks of text264+* [go-runewidth][runewidth]: Measure the physical width of strings in terms of terminal cells. Many runes, such as East Asian charcters and emojis, are two cells wide, so measuring a layout with `len()` often won't cut it.265+266+[termenv]: https://github.com/muesli/termenv267+[reflow]: https://github.com/muesli/reflow268+[bubbles]: https://github.com/charmbracelet/bubbles269+[runewidth]: https://github.com/mattn/go-runewidth270+271+### Feedback272+273+We'd love to hear your thoughts on this tutorial. Feel free to drop us a note!274+275+* [Twitter](https://twitter.com/charmcli)276+* [The Fediverse](https://mastodon.technology/@charm)277+278 ### What's Next?279 280 This tutorial covers the basics of building an interactive terminal UI, but281 in the real world you'll also need to perform I/O. To learn about that have a50 unmodified lines