Skip to content

Commit 50223fd

Browse files
committed
Merge branch 'v2-exp' into dlvhdr/tree-example
1 parent 9f096b6 commit 50223fd

159 files changed

Lines changed: 5196 additions & 3733 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ updates:
1313
commit-message:
1414
prefix: "chore"
1515
include: "scope"
16+
groups:
17+
all:
18+
patterns:
19+
- "*"
20+
ignore:
21+
- dependency-name: github.com/charmbracelet/bubbletea/v2
22+
versions:
23+
- v2.0.0-beta1
1624

1725
- package-ecosystem: "github-actions"
1826
directory: "/"
@@ -26,6 +34,10 @@ updates:
2634
commit-message:
2735
prefix: "chore"
2836
include: "scope"
37+
groups:
38+
all:
39+
patterns:
40+
- "*"
2941

3042
- package-ecosystem: "docker"
3143
directory: "/"
@@ -37,8 +49,12 @@ updates:
3749
labels:
3850
- "dependencies"
3951
commit-message:
40-
prefix: "feat"
52+
prefix: "chore"
4153
include: "scope"
54+
groups:
55+
all:
56+
patterns:
57+
- "*"
4258

4359
- package-ecosystem: "gomod"
4460
directory: "/examples"
@@ -52,6 +68,10 @@ updates:
5268
commit-message:
5369
prefix: "chore"
5470
include: "scope"
71+
groups:
72+
all:
73+
patterns:
74+
- "*"
5575

5676
- package-ecosystem: "gomod"
5777
directory: "/tutorials"
@@ -65,3 +85,7 @@ updates:
6585
commit-message:
6686
prefix: "chore"
6787
include: "scope"
88+
groups:
89+
all:
90+
patterns:
91+
- "*"

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
GO111MODULE: "on"
1313
steps:
1414
- name: Install Go
15-
uses: actions/setup-go@v5
15+
uses: actions/setup-go@v6
1616
with:
1717
go-version: ${{ matrix.go-version }}
1818

1919
- name: Checkout code
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v6
2121

2222
- name: Coverage
2323
run: |

.github/workflows/examples.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ jobs:
2020
contents: write
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v4
24-
- uses: actions/setup-go@v5
23+
- uses: actions/checkout@v6
24+
- uses: actions/setup-go@v6
2525
with:
2626
go-version: '^1'
2727
cache: true
2828
- shell: bash
2929
run: |
3030
(cd ./examples && go mod tidy)
3131
(cd ./tutorials && go mod tidy)
32-
- uses: stefanzweifel/git-auto-commit-action@v5
32+
- uses: stefanzweifel/git-auto-commit-action@v7
3333
with:
3434
commit_message: "chore: go mod tidy tutorials and examples"
3535
branch: master

.github/workflows/lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ on:
66
jobs:
77
lint:
88
uses: charmbracelet/meta/.github/workflows/lint.yml@main
9+
with:
10+
golangci_path: .golangci.yml
11+
golangci_version: v2.9
12+
timeout: 10m

.golangci.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ linters:
77
- exhaustive
88
- goconst
99
- godot
10-
- godox
1110
- gomoddirectives
1211
- goprintffuncname
1312
- gosec
@@ -27,13 +26,13 @@ linters:
2726
- whitespace
2827
- wrapcheck
2928
exclusions:
29+
rules:
30+
- text: '(slog|log)\.\w+'
31+
linters:
32+
- noctx
3033
generated: lax
3134
presets:
3235
- common-false-positives
33-
paths:
34-
- third_party$
35-
- builtin$
36-
- examples$
3736
issues:
3837
max-issues-per-linter: 0
3938
max-same-issues: 0
@@ -43,7 +42,3 @@ formatters:
4342
- goimports
4443
exclusions:
4544
generated: lax
46-
paths:
47-
- third_party$
48-
- builtin$
49-
- examples$

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020-2023 Charmbracelet, Inc
3+
Copyright (c) 2020-2026 Charmbracelet, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
# Bubble Tea
22

33
<p>
4-
<picture>
5-
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/bubbletea/bubble-tea-v2-light.png" width="308">
6-
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/bubbletea/bubble-tea-v2-dark.png" width="312">
7-
<img src="https://stuff.charm.sh/bubbletea/bubble-tea-v2-light.png" width="308" />
8-
</picture>
9-
<br>
4+
<img src="https://github.com/user-attachments/assets/ad408275-8799-488f-9303-441e7f869535" width="350"><br>
105
<a href="https://github.com/charmbracelet/bubbletea/releases"><img src="https://img.shields.io/github/release/charmbracelet/bubbletea.svg" alt="Latest Release"></a>
11-
<a href="https://pkg.go.dev/github.com/charmbracelet/bubbletea?tab=doc"><img src="https://godoc.org/github.com/charmbracelet/bubbletea?status.svg" alt="GoDoc"></a>
12-
<a href="https://github.com/charmbracelet/bubbletea/actions"><img src="https://github.com/charmbracelet/bubbletea/actions/workflows/build.yml/badge.svg" alt="Build Status"></a>
13-
<a href="https://www.phorm.ai/query?projectId=a0e324b6-b706-4546-b951-6671ea60c13f"><img src="https://stuff.charm.sh/misc/phorm-badge.svg" alt="phorm.ai"></a>
6+
<a href="https://pkg.go.dev/charm.land/bubbletea/v2?tab=doc"><img src="https://godoc.org/charm.land/bubbletea/v2?status.svg" alt="GoDoc"></a>
7+
<a href="https://github.com/charmbracelet/bubbletea/actions"><img src="https://github.com/charmbracelet/bubbletea/actions/workflows/build.yml/badge.svg?branch=main" alt="Build Status"></a>
148
</p>
159

1610
The fun, functional and stateful way to build terminal apps. A Go framework
@@ -23,19 +17,24 @@ complex terminal applications, either inline, full-window, or a mix of both.
2317

2418
Bubble Tea is in use in production and includes a number of features and
2519
performance optimizations we’ve added along the way. Among those is
26-
a framerate-based renderer, mouse support, focus reporting and more.
20+
a high-performance cell-based renderer, built-in color downsampling,
21+
declarative views, high-fidelity keyboard and mouse handling, native clipboard
22+
support, and more.
2723

2824
To get started, see the tutorial below, the [examples][examples], the
29-
[docs][docs], the [video tutorials][youtube] and some common [resources](#libraries-we-use-with-bubble-tea).
25+
[docs][docs], and some common [resources](#libraries-we-use-with-bubble-tea).
3026

31-
[youtube]: https://charm.sh/yt
27+
> [!TIP]
28+
>
29+
> Upgrading from v1? Check out the [upgrade guide](./UPGRADE_GUIDE_V2.md), or
30+
> point your LLM at it and let it go to town.
3231
3332
## By the way
3433

3534
Be sure to check out [Bubbles][bubbles], a library of common UI components for Bubble Tea.
3635

3736
<p>
38-
<a href="https://github.com/charmbracelet/bubbles"><img src="https://stuff.charm.sh/bubbles/bubbles-badge.png" width="174" alt="Bubbles Badge"></a>&nbsp;&nbsp;
37+
<a href="https://github.com/charmbracelet/bubbles"><img src="https://github.com/user-attachments/assets/b6dc4638-b67a-4bfa-88d0-a8e8833c3ac9" width="172" alt="Bubbles Badge"></a>&nbsp;&nbsp;
3938
<a href="https://github.com/charmbracelet/bubbles"><img src="https://stuff.charm.sh/bubbles-examples/textinput.gif" width="400" alt="Text Input Example from Bubbles"></a>
4039
</p>
4140

@@ -73,7 +72,7 @@ import (
7372
"fmt"
7473
"os"
7574

76-
tea "github.com/charmbracelet/bubbletea/v2"
75+
tea "charm.land/bubbletea/v2"
7776
)
7877
```
7978

@@ -99,31 +98,39 @@ type model struct {
9998

10099
## Initialization
101100

102-
Next, we’ll define our application’s initial state in the `Init` method. `Init`
103-
can return a `Cmd` that could perform some initial I/O. For now, we don't need
104-
to do any I/O, so for the command, we'll just return `nil`, which translates to
105-
"no command."
101+
Next, we’ll define our application’s initial state. `Init` can return a `Cmd`
102+
that could perform some initial I/O. For now, we don’t need to do any I/O, so
103+
for the command, we’ll just return `nil`, which translates to “no command.”
106104

107105
```go
108-
func (m model) Init() (tea.Model, tea.Cmd) {
109-
m = {
106+
func initialModel() model {
107+
return model{
110108
// Our to-do list is a grocery list
111109
choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},
112110

113111
// A map which indicates which choices are selected. We're using
114-
// the map like a mathematical set. The keys refer to the indexes
112+
// the map like a mathematical set. The keys refer to the indexes
115113
// of the `choices` slice, above.
116114
selected: make(map[int]struct{}),
117115
}
116+
}
117+
```
118118

119+
After that, we’ll define our application’s initial state in the `Init` method. `Init`
120+
can return a `Cmd` that could perform some initial I/O. For now, we don't need
121+
to do any I/O, so for the command, we'll just return `nil`, which translates to
122+
"no command."
123+
124+
```go
125+
func (m model) Init() tea.Cmd {
119126
// Just return `nil`, which means "no I/O right now, please."
120-
return m, nil
127+
return nil
121128
}
122129
```
123130

124131
### The Update Method
125132

126-
Next up is the update method. The update function is called when things
133+
Next up is the update method. The update function is called when things
127134
happen.” Its job is to look at what has happened and return an updated model in
128135
response. It can also return a `Cmd` to make more things happen, but for now
129136
don't worry about that part.
@@ -167,8 +174,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
167174
m.cursor++
168175
}
169176

170-
// The "enter" key and the space bar (a literal space) toggle the
171-
// selected state for the item that the cursor is pointing at.
177+
// The "enter" key and the space bar toggle the selected state
178+
// for the item that the cursor is pointing at.
172179
case "enter", "space":
173180
_, ok := m.selected[m.cursor]
174181
if ok {
@@ -192,15 +199,16 @@ the Bubble Tea runtime to quit, exiting the program.
192199
### The View Method
193200

194201
At last, it’s time to render our UI. Of all the methods, the view is the
195-
simplest. We look at the model in its current state and use it to return
196-
a `string`. That string is our UI!
202+
simplest. We look at the model in its current state and use it to build a
203+
`tea.View`. The view declares our UI content and, optionally, terminal features
204+
like alt screen mode, mouse tracking, cursor position, and more.
197205

198206
Because the view describes the entire UI of your application, you don’t have to
199207
worry about redrawing logic and stuff like that. Bubble Tea takes care of it
200208
for you.
201209

202210
```go
203-
func (m model) View() string {
211+
func (m model) View() tea.View {
204212
// The header
205213
s := "What should we buy at the market?\n\n"
206214

@@ -227,7 +235,7 @@ func (m model) View() string {
227235
s += "\nPress q to quit.\n"
228236

229237
// Send the UI for rendering
230-
return s
238+
return tea.NewView(s)
231239
}
232240
```
233241

@@ -257,7 +265,7 @@ there are [Go Docs][docs].
257265

258266
[cmd]: https://github.com/charmbracelet/bubbletea/tree/main/tutorials/commands/
259267
[examples]: https://github.com/charmbracelet/bubbletea/tree/main/examples
260-
[docs]: https://pkg.go.dev/github.com/charmbracelet/bubbletea?tab=doc
268+
[docs]: https://pkg.go.dev/charm.land/bubbletea/v2?tab=doc
261269

262270
## Debugging
263271

@@ -320,7 +328,7 @@ your program in another window.
320328

321329
## Bubble Tea in the Wild
322330

323-
There are over [10,000 applications](https://github.com/charmbracelet/bubbletea/network/dependents) built with Bubble Tea! Here are a handful of ’em.
331+
There are over [18,000 applications](https://github.com/charmbracelet/bubbletea/network/dependents) built with Bubble Tea! Here are a handful of ’em.
324332

325333
### Staff favourites
326334

@@ -333,14 +341,14 @@ There are over [10,000 applications](https://github.com/charmbracelet/bubbletea/
333341

334342
### In Industry
335343

336-
- Microsoft Azure – [Aztify](https://github.com/Azure/aztfy): bring Microsoft Azure resources under Terraform
337-
- Daytona – [Daytona](https://github.com/daytonaio/daytona): open source dev environment manager
344+
- Microsoft Azure – [Aztify](https://github.com/Azure/aztfy): bring Microsoft Azure resources under Terraform
345+
- Daytona – [Daytona](https://github.com/daytonaio/daytona): an AI infrastructure platform
338346
- Cockroach Labs – [CockroachDB](https://github.com/cockroachdb/cockroach): a cloud-native, high-availability distributed SQL database
339-
- Truffle Security Co. – [Trufflehog](https://github.com/trufflesecurity/trufflehog): find leaked credentials
340-
- NVIDIA – [container-canary](https://github.com/NVIDIA/container-canary): a container validator
341-
- AWS – [eks-node-viewer](https://github.com/awslabs/eks-node-viewer): a tool for visualizing dynamic node usage within an EKS cluster
342-
- MinIO – [mc](https://github.com/minio/mc): the official [MinIO](https://min.io) client
343-
- Ubuntu – [Authd](https://github.com/ubuntu/authd): an authentication daemon for cloud-based identity providers
347+
- Truffle Security Co. – [Trufflehog](https://github.com/trufflesecurity/trufflehog): find leaked credentials
348+
- NVIDIA – [container-canary](https://github.com/NVIDIA/container-canary): a container validator
349+
- AWS – [eks-node-viewer](https://github.com/awslabs/eks-node-viewer): a tool for visualizing dynamic node usage within an EKS cluster
350+
- MinIO – [mc](https://github.com/minio/mc): the official [MinIO](https://min.io) client
351+
- Ubuntu – [Authd](https://github.com/ubuntu/authd): an authentication daemon for cloud-based identity providers
344352

345353
### Charm stuff
346354

@@ -389,6 +397,6 @@ of days past.
389397

390398
Part of [Charm](https://charm.sh).
391399

392-
<a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a>
400+
<a href="https://charm.sh/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-banner-next.jpg" width="400"></a>
393401

394402
Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة

0 commit comments

Comments
 (0)