docs: readme improvements (#448)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* docs: fix hierarchy in literate version of the basics tutorial * docs: small correction to comment in literate tutorial * docs: improve wording in logging section of the README * docs: fix spelling (thanks maas)
authored by Christian Rocha · committed by GitHub · parent d0f3e1e · Browse files · 2 files·+18 added−18 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+18 added−18 removed
- other:+18 added−18 removed
Provenance
- Commit
bf39962- Tree
34a492b- Author
Christian Rocha <christian@rocha.is>- Committer
GitHub <noreply@github.com>- Parent
d0f3e1e
2 files changed+18 added−18 removed
modified:tutorials/basics/README.md+1 added-1 removed
57 unmodified lines58 59 ```go60 func initialModel() model {61 return model{62- // Our shopping list is a grocery list62+ // Our to-do list is a grocery list63 choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},64 65 // A map which indicates which choices are selected. We're using66 // the map like a mathematical set. The keys refer to the indexes175 unmodified linesmodified:README.md+17 added-17 removed
1-Bubble Tea2-==========1+# Bubble Tea2 3 <p>4 <img src="https://stuff.charm.sh/bubbletea/bubbletea-github-header-simple.png" width="313" alt="Bubble Tea Title Treatment"><br>5 <a href="https://github.com/charmbracelet/bubbletea/releases"><img src="https://img.shields.io/github/release/charmbracelet/bubbletea.svg" alt="Latest Release"></a>44 unmodified lines50 This tutorial assumes you have a working knowledge of Go.51 52 [elm]: https://guide.elm-lang.org/architecture/53 55-## Enough! Let's get to it.54+### Enough! Let's get to it.55 56 For this tutorial, we're making a shopping list.57 58 To start we'll define our package and import some libraries. Our only external16 unmodified lines75 * **Init**, a function that returns an initial command for the application to run.76 * **Update**, a function that handles incoming events and updates the model accordingly.77 * **View**, a function that renders the UI based on the data in the model.78 80-## The Model79+### The Model80 81 So let's start by defining our model which will store our application's state.82 It can be any type, but a `struct` usually makes the most sense.83 4 unmodified lines88 selected map[int]struct{} // which to-do items are selected89 }90 ```91 93-## Initialization92+### Initialization93 94 Next, we’ll define our application’s initial state. In this case, we’re defining95 a function to return our initial model, however, we could just as easily define96 the initial model as a variable elsewhere, too.97 98 ```go99 func initialModel() model {100 return model{102- // Our shopping list is a grocery list101+ // Our to-do list is a grocery list102 choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},103 104 // A map which indicates which choices are selected. We're using105 // the map like a mathematical set. The keys refer to the indexes13 unmodified lines119 return nil120 }121 ```122 124-## The Update Method123+### The Update Method124 125 Next up is the update method. The update function is called when ”things126 happen.” Its job is to look at what has happened and return an updated model in127 response. It can also return a `Cmd` to make more things happen, but for now59 unmodified lines187 You may have noticed that <kbd>ctrl+c</kbd> and <kbd>q</kbd> above return188 a `tea.Quit` command with the model. That’s a special command which instructs189 the Bubble Tea runtime to quit, exiting the program.190 192-## The View Method191+### The View Method192 193 At last, it’s time to render our UI. Of all the methods, the view is the194 simplest. We look at the model in its current state and use it to return196-a `string`. That string is our UI!195+a `string`. That string is our UI!196 197 Because the view describes the entire UI of your application, you don’t have to198 worry about redrawing logic and stuff like that. Bubble Tea takes care of it199 for you.29 unmodified lines229 return s230 }231 ```232 234-## All Together Now233+### All Together Now234 235 The last step is to simply run our program. We pass our initial model to236 `tea.NewProgram` and let it rip:237 40 unmodified lines278 actually watch out what address the first `dlv` run tells you to connect to.279 280 ### Logging Stuff281 283-You can log to a debug file to print debug Bubble Tea applications. To do so,284-include something like…282+You can’t really log to stdout with Bubble Tea because your TUI is busy283+occupying that! You can, however, log to a file by including something like284+the following prior to starting your Bubble Tea program:285 286 ```go287 if len(os.Getenv("DEBUG")) > 0 {288 f, err := tea.LogToFile("debug.log", "debug")4 unmodified lines293 defer f.Close()294 }295 ```296 297-…before you start your Bubble Tea program. To see what’s printed in real time,298-run `tail -f debug.log` while you run your program in another window.297+To see what’s being logged in real time, run `tail -f debug.log` while you run298+your program in another window.299 300 ## Libraries we use with Bubble Tea301 302 * [Bubbles][bubbles]: Common Bubble Tea components such as text inputs, viewports, spinners and so on23 unmodified lines326 * [container-canary](https://github.com/NVIDIA/container-canary): a container validator327 * [dns53](https://github.com/purpleclay/dns53): dynamic DNS with Amazon Route53. Expose your EC2 quickly, securely and privately328 * [fm](https://github.com/knipferrc/fm): a terminal-based file manager329 * [flapioca](https://github.com/kbrgl/flapioca): Flappy Bird on the CLI!330-* [fztea](https://github.com/jon4hz/fztea): connect to your Flipper's UI over serial or make it accessible via SSH 330+* [fztea](https://github.com/jon4hz/fztea): connect to your Flipper's UI over serial or make it accessible via SSH331 * [fork-cleaner](https://github.com/caarlos0/fork-cleaner): cleans up old and inactive forks in your GitHub account332 * [gambit](https://github.com/maaslalani/gambit): play chess in the terminal333 * [gembro](https://git.sr.ht/~rafael/gembro): a mouse-driven Gemini browser334 * [gh-b](https://github.com/joaom00/gh-b): GitHub CLI extension to easily manage your branches49 unmodified lines384 ## License385 386 [MIT](https://github.com/charmbracelet/bubbletea/raw/master/LICENSE)387 388-***388+* * *389 390 Part of [Charm](https://charm.sh).391 392 <a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a>393 394-Charm热爱开源 • Charm loves open source394+Charm 热爱开源 • Charm loves open source