Skip to content

πŸ“š Learning and exploring the Go-based TUI framework: Bubble Tea

Notifications You must be signed in to change notification settings

dgroomes/bubble-tea-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

bubble-tea-playground

πŸ“š Learning and exploring the Go-based TUI framework: Bubble Tea.

The fun, functional and stateful way to build terminal apps.

-- https://github.com/charmbracelet/bubbletea

Description

Charm is building perhaps the best overall CLI tools in existence. They build a collection of open-source projects that have a particular focus on making CLI experiences sophisticated, stylish, and smooth around the edges.

I'd like to start by learning how to use Charm's TUI (Text User Interface) framework: Bubble Tea.

Instructions

Follow these instructions to build and run some Bubble Tea example programs.

  1. Build and run the file summarizer program:
    • go run bubble_tea_playground/pkg/file-summarizer
    • Altogether it will look something like the following.
    • go run .
      
      What files should we summarize?
      
      > [ ] go.mod
        [ ] go.sum
        [ ] README.md
        [ ] .gitignore
        [ ] file-summarizer.go
        [ ] .idea
      
      Press 'e' to execute the file summarization. Press 'q' to quit.
      
    • What files should we summarize?
      
        [ ] go.mod
        [ ] go.sum
        [x] README.md
        [ ] .gitignore
        [ ] file-summarizer.go
      > [x] .idea
      
      Press 'e' to execute the file summarization. Press 'q' to quit.
      
    • Complete! Below is a summary of the selected files. It shows each file size, in bytes:
      ["README.md: 1630" ".idea: 192"]
      
  2. Now, let's implement similar functionality but in a fancy list TUI component.
    • go run bubble_tea_playground/pkg/git-project-file-summarizer

Wish List

General clean-ups, TODOs and things I wish to implement for this project

  • Handle when there are no files selected. Use a different message.
  • DONE Other UI components? Can I do a table (yes)? I'm going to implement a "fancy list". This is a much more "in the weeds" example. I've got something working, I want to refactor it and also add the spinner animation.
    • DONE Functional program
    • DONE (sort of; using a 'domain.go' file) Consider splitting out a "core/domain" package/file
    • DONE (sort of; using a 'domain.go' file) Consider splitting out a "git" package/file
    • Defect. When I press enter on an entry to start fetching its size and then quickly press '/' to start filtering and then type some characters, the list filters down to empty even if the filter should match an entry.
    • DONE Go back to value variables (fewer pointers) and allow the Bubble Tea "Update" function to have more logic. The experiment was useful, but I want this demo to settle on idiomatic Bubble Tea.
  • Add spinner animation

Reference

About

πŸ“š Learning and exploring the Go-based TUI framework: Bubble Tea

Topics

Resources

Stars

Watchers

Forks

Languages