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.
23 lines
463 B
Go
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()
|
|
}
|