Skip to content

Commit

Permalink
Merge pull request #275 from overmindtech/spinner-align
Browse files Browse the repository at this point in the history
Align spinner with the rest of task models
  • Loading branch information
DavidS-ovm authored May 8, 2024
2 parents 4031513 + 50f7821 commit a2a7a25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 9 additions & 1 deletion cmd/tea_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/ansi"
)

// waitForCancellation returns a tea.Cmd that will wait for SIGINT and SIGTERM and run the provided cancel on receipt.
Expand Down Expand Up @@ -59,7 +60,7 @@ func NewTaskModel(title string) taskModel {
status: taskStatusPending,
title: title,
spinner: spinner.New(
spinner.WithSpinner(spinner.Pulse),
spinner.WithSpinner(spinner.Moon),
spinner.WithStyle(lipgloss.NewStyle().Foreground(lipgloss.Color(ColorPalette.Light.BgMain))),
),
}
Expand Down Expand Up @@ -94,6 +95,13 @@ func (m taskModel) View() string {
case taskStatusPending:
return fmt.Sprintf("⏳ %v", m.title)
case taskStatusRunning:
v := m.spinner.View()
switch ansi.PrintableRuneWidth(v) {
case 0:
v = " "
case 1:
v += " "
}
return fmt.Sprintf("%v %v", m.spinner.View(), m.title)
case taskStatusDone:
return fmt.Sprintf("✅ %v", m.title)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/hexops/gotextdiff v1.0.3
github.com/jedib0t/go-pretty/v6 v6.5.8
github.com/mattn/go-isatty v0.0.20
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6
github.com/muesli/termenv v0.15.2
github.com/overmindtech/aws-source v0.0.0-20240508085257-231b53ce8183
github.com/overmindtech/sdp-go v0.73.0
Expand Down Expand Up @@ -112,7 +113,6 @@ require (
github.com/miekg/dns v1.1.59 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/nats-io/jwt/v2 v2.5.6 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/openrdap/rdap v0.9.2-0.20240219192926-2210b535d40b h1:sM/kMuT+cm9hsSaZGVkGgwKHpQN3Et5/DF9zX/02X6w=
github.com/openrdap/rdap v0.9.2-0.20240219192926-2210b535d40b/go.mod h1:391Ww1JbjG4FHOlvQqCd6n25CCCPE64JzC5cCYPxhyM=
github.com/overmindtech/aws-source v0.0.0-20240503163311-8aa534dcedaf h1:9cWd0VvDNLcpG+JjHTyw8Gq3fmNNwd76XH86iXQhI7w=
github.com/overmindtech/aws-source v0.0.0-20240503163311-8aa534dcedaf/go.mod h1:D19TNLEWI3iYN4bnHN+7j+Y33LQxKVF+cIomxdGvJmg=
github.com/overmindtech/aws-source v0.0.0-20240508085257-231b53ce8183 h1:hiHkQLQPUk3PtiEIh31RFq9gMNJaRtyoCKIDkkT3ePc=
github.com/overmindtech/aws-source v0.0.0-20240508085257-231b53ce8183/go.mod h1:mhuyd9sRBae4Y/URsrIUGZr6t9P6Ee8mHpCgoCMLUiw=
github.com/overmindtech/discovery v0.27.0 h1:pti9Tk3gwFxt7S6P+dBTKD0v29BjgQhnbZObSyrJMmg=
Expand All @@ -228,8 +226,6 @@ github.com/overmindtech/sdp-go v0.73.0 h1:zo+lpPsWn3znM9BT8jA5IUrbCD39otGNUxK7sF
github.com/overmindtech/sdp-go v0.73.0/go.mod h1:+pAlm26clqfEycxBlf+n8YFYZZ5puGeqED6lfz/bBi4=
github.com/overmindtech/sdpcache v1.6.4 h1:MJoYBDqDE3s8FrRzZ0RPgFiH39HWI/Mv2ImH1NdLT8k=
github.com/overmindtech/sdpcache v1.6.4/go.mod h1:/F9XStVdntRJEQjlZ86BPuB1Y7VPo1PFcsCNiU1IoGE=
github.com/overmindtech/stdlib-source v0.0.0-20240503161949-5174af9973ae h1:/gWwW4Mii+MC2K0c7GA4ie8YvdJeN6qxXvZgXfznu3s=
github.com/overmindtech/stdlib-source v0.0.0-20240503161949-5174af9973ae/go.mod h1:11aouebgyNhOO/VO+WbOuVZlQ3kvKThbwIgk2ihBLPU=
github.com/overmindtech/stdlib-source v0.0.0-20240508084908-a929a97f2f4e h1:PTU4Fo6FeQVg2CIOC3279rkC/J9hGcSFPgWLrPGa+1g=
github.com/overmindtech/stdlib-source v0.0.0-20240508084908-a929a97f2f4e/go.mod h1:ApKGJbHQY4t7KybMns0TUUuYYlASJ44gJJNa7lC/tV8=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
Expand Down

0 comments on commit a2a7a25

Please sign in to comment.