mirror of
https://github.com/charmbracelet/gum
synced 2024-06-10 17:52:20 +02:00
29 lines
712 B
Go
29 lines
712 B
Go
package spin
|
|
|
|
import (
|
|
"github.com/alecthomas/kong"
|
|
"github.com/charmbracelet/bubbles/spinner"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/charmbracelet/gum/style"
|
|
)
|
|
|
|
// 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()
|
|
}
|
|
|
|
// BeforeReset hook. Used to unclutter style flags.
|
|
func (o Options) BeforeReset(ctx *kong.Context) error {
|
|
return style.HideFlags(ctx)
|
|
}
|