~/Bubble Tea
Nov 3, 2024
Bubble Tea is a popular Golang framework for building TUI applications. Though the initial learning curve is somewhat steep, the setup amounts to only about 30 lines of code, consider the following example.
|
|
Skipping the self explanatory code, The Init
function can be used to run an initial command for your application, here is an example of such a command.
This may not make much sense as it will exit the application as soon as it begins, lets try another.
ClearScreen
will clear the terminal as part of the Initialization.
Looking at our Update
function:
The Update
function will simply check if (any) button was pressed and increment the
value of x, terminating the application in case the value is 10 or above.
I’ll admit this View
function is simplistic but it does the job,
Here we take a value from our model and populate our….very simple UI to show
the number of clicks needed until the program exists. All the View
does is return a string that the user views in their terminal with their eyes.
References