gum/progress/command.go
Maas Lalani 7190822247
refactor(kong): Implement Run(...) error interface
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.
2022-07-12 22:33:52 -04:00

23 lines
463 B
Go

package progress
import (
"os"
"github.com/charmbracelet/bubbles/progress"
tea "github.com/charmbracelet/bubbletea"
)
// Run runs the progress command.
func (o Options) Run() error {
p := progress.New(
progress.WithGradient(o.ColorStart, o.ColorEnd),
progress.WithSpringOptions(o.Frequency, o.Damping),
)
m := model{
progress: p,
interval: o.Interval,
increment: o.Increment,
}
return tea.NewProgram(m, tea.WithOutput(os.Stderr)).Start()
}