mirror of
https://github.com/charmbracelet/gum
synced 2024-06-08 08:42:16 +02:00
7190822247
Instead of needing to run the commands manually in main.go, we can implement the `Run(...) error` method to satisfy the command interface so that `kong` can Run our commands for us.
22 lines
504 B
Go
22 lines
504 B
Go
package spin
|
|
|
|
import (
|
|
"github.com/charmbracelet/bubbles/spinner"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
// Run provides a shell script interface for the spinner bubble.
|
|
// https://github.com/charmbracelet/bubbles/spinner
|
|
func (o Options) Run() error {
|
|
s := spinner.New()
|
|
s.Style = o.SpinnerStyle.ToLipgloss()
|
|
s.Spinner = spinnerMap[o.Spinner]
|
|
m := model{
|
|
spinner: s,
|
|
title: o.TitleStyle.ToLipgloss().Render(o.Title),
|
|
command: o.Command,
|
|
}
|
|
p := tea.NewProgram(m)
|
|
return p.Start()
|
|
}
|