Skip to content

Commit e00d512

Browse files
authored
Initial commit
0 parents  commit e00d512

12 files changed

+325
-0
lines changed

.github/dependabot.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
time: "08:00"
8+
labels:
9+
- "dependencies"
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "daily"
14+
time: "08:00"
15+
labels:
16+
- "dependencies"

.github/workflows/build.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: build
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-go@v5
16+
with:
17+
go-version: stable
18+
- name: test
19+
run: |
20+
go test -v -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./...
21+
- uses: codecov/codecov-action@v3
22+
if: matrix.os == 'ubuntu-latest'
23+
with:
24+
token: ${{ secrets.CODECOV_TOKEN }}
25+
file: ./coverage.txt

.github/workflows/lint.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
golangci:
11+
name: lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-go@v5
16+
with:
17+
go-version: stable
18+
- name: golangci-lint
19+
uses: golangci/golangci-lint-action@v3
20+
with:
21+
skip-go-installation: true

.github/workflows/release.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
packages: write
12+
13+
jobs:
14+
goreleaser:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: stable
23+
- uses: goreleaser/goreleaser-action@v5
24+
with:
25+
version: latest
26+
args: release --clean
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage.txt
2+
dist/

.golangci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
linters:
2+
enable:
3+
- thelper
4+
- gofumpt
5+
- tparallel
6+
- unconvert
7+
- unparam
8+
- wastedassign

.goreleaser.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
gomod:
8+
proxy: true
9+
10+
builds:
11+
- env: ["CGO_ENABLED=0"]
12+
mod_timestamp: "{{ .CommitTimestamp }}"
13+
flags: ["-trimpath"]
14+
targets: ["go_first_class"]
15+
16+
changelog:
17+
sort: asc
18+
use: github
19+
filters:
20+
exclude:
21+
- "^docs:"
22+
- "^test:"
23+
- "^chore"
24+
- Merge pull request
25+
- Merge remote-tracking branch
26+
- Merge branch
27+
- go mod tidy
28+
groups:
29+
- title: "New Features"
30+
regexp: "^.*feat[(\\w)]*:+.*$"
31+
order: 0
32+
- title: "Bug fixes"
33+
regexp: "^.*fix[(\\w)]*:+.*$"
34+
order: 10
35+
- title: Other work
36+
order: 999
37+
38+
release:
39+
footer: |
40+
41+
---
42+
43+
_Released with [GoReleaser](https://goreleaser.com)!_

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022-2023 Charmbracelet, Inc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# bubbletea-app-template
2+
3+
A template repository to create [Bubbletea][bubbletea] apps.
4+
5+
## Included
6+
7+
- a sample app that does nothing, so it includes all dependencies:
8+
- [bubbletea][]
9+
- [bubbles][]
10+
- [lipgloss][]
11+
- github actions workflows for build, test, lint and release
12+
- [GoReleaser][goreleaser] configs
13+
- [golangci-lint][lint] configs
14+
15+
[bubbletea]: https://github.com/charmbracelet/bubbletea
16+
[bubbles]: https://github.com/charmbracelet/bubbles
17+
[lipgloss]: https://github.com/charmbracelet/lipgloss
18+
[goreleaser]: https://goreleaser.com
19+
[lint]: https://golangci-lint.run

go.mod

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module github.com/charmbracelet/bubbletea-app-template
2+
3+
go 1.19
4+
5+
require (
6+
github.com/charmbracelet/bubbles v0.17.1
7+
github.com/charmbracelet/bubbletea v0.25.0
8+
github.com/charmbracelet/lipgloss v0.9.1
9+
)
10+
11+
require (
12+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
13+
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
14+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
15+
github.com/mattn/go-isatty v0.0.18 // indirect
16+
github.com/mattn/go-localereader v0.0.1 // indirect
17+
github.com/mattn/go-runewidth v0.0.15 // indirect
18+
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
19+
github.com/muesli/cancelreader v0.2.2 // indirect
20+
github.com/muesli/reflow v0.3.0 // indirect
21+
github.com/muesli/termenv v0.15.2 // indirect
22+
github.com/rivo/uniseg v0.2.0 // indirect
23+
golang.org/x/sync v0.1.0 // indirect
24+
golang.org/x/sys v0.12.0 // indirect
25+
golang.org/x/term v0.6.0 // indirect
26+
golang.org/x/text v0.3.8 // indirect
27+
)

go.sum

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
2+
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
3+
github.com/charmbracelet/bubbles v0.17.1 h1:0SIyjOnkrsfDo88YvPgAWvZMwXe26TP6drRvmkjyUu4=
4+
github.com/charmbracelet/bubbles v0.17.1/go.mod h1:9HxZWlkCqz2PRwsCbYl7a3KXvGzFaDHpYbSYMJ+nE3o=
5+
github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM=
6+
github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg=
7+
github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg=
8+
github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I=
9+
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
10+
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
11+
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
12+
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
13+
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
14+
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
15+
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
16+
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
17+
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
18+
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
19+
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
20+
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
21+
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
22+
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
23+
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
24+
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
25+
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
26+
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
27+
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
28+
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
29+
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
30+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
31+
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
32+
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
33+
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
34+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
35+
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
36+
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
37+
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
38+
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
39+
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
40+
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=

main.go

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/charmbracelet/bubbles/key"
8+
"github.com/charmbracelet/bubbles/spinner"
9+
tea "github.com/charmbracelet/bubbletea"
10+
"github.com/charmbracelet/lipgloss"
11+
)
12+
13+
type errMsg error
14+
15+
type model struct {
16+
spinner spinner.Model
17+
quitting bool
18+
err error
19+
}
20+
21+
var quitKeys = key.NewBinding(
22+
key.WithKeys("q", "esc", "ctrl+c"),
23+
key.WithHelp("", "press q to quit"),
24+
)
25+
26+
func initialModel() model {
27+
s := spinner.New()
28+
s.Spinner = spinner.Dot
29+
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
30+
return model{spinner: s}
31+
}
32+
33+
func (m model) Init() tea.Cmd {
34+
return m.spinner.Tick
35+
}
36+
37+
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
38+
switch msg := msg.(type) {
39+
40+
case tea.KeyMsg:
41+
if key.Matches(msg, quitKeys) {
42+
m.quitting = true
43+
return m, tea.Quit
44+
45+
}
46+
return m, nil
47+
case errMsg:
48+
m.err = msg
49+
return m, nil
50+
51+
default:
52+
var cmd tea.Cmd
53+
m.spinner, cmd = m.spinner.Update(msg)
54+
return m, cmd
55+
}
56+
}
57+
58+
func (m model) View() string {
59+
if m.err != nil {
60+
return m.err.Error()
61+
}
62+
str := fmt.Sprintf("\n\n %s Loading forever... %s\n\n", m.spinner.View(), quitKeys.Help().Desc)
63+
if m.quitting {
64+
return str + "\n"
65+
}
66+
return str
67+
}
68+
69+
func main() {
70+
p := tea.NewProgram(initialModel())
71+
if _, err := p.Run(); err != nil {
72+
fmt.Println(err)
73+
os.Exit(1)
74+
}
75+
}

0 commit comments

Comments
 (0)