9 tea "charm.land/bubbletea/v2"
10 "github.com/charmbracelet/crush/internal/tui/components/anim"
11 "github.com/charmbracelet/x/ansi"
14// Spinner wraps the bubbles spinner for non-interactive mode
21 cancel context.CancelFunc
25func (m model) Init() tea.Cmd { return m.anim.Init() }
26func (m model) View() tea.View { return tea.NewView(m.anim.View()) }
28// Update implements tea.Model.
29func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
30 switch msg := msg.(type) {
38 mm, cmd := m.anim.Update(msg)
39 m.anim = mm.(*anim.Anim)
43// NewSpinner creates a new spinner with the given message
44func NewSpinner(ctx context.Context, cancel context.CancelFunc, animSettings anim.Settings) *Spinner {
46 anim: anim.New(animSettings),
50 p := tea.NewProgram(m, tea.WithOutput(os.Stderr), tea.WithContext(ctx))
54 done: make(chan struct{}, 1),
58// Start begins the spinner animation
59func (s *Spinner) Start() {
62 _, err := s.prog.Run()
63 // ensures line is cleared
64 fmt.Fprint(os.Stderr, ansi.EraseEntireLine)
65 if err != nil && !errors.Is(err, context.Canceled) && !errors.Is(err, tea.ErrInterrupted) {
66 fmt.Fprintf(os.Stderr, "Error running spinner: %v\n", err)
71// Stop ends the spinner animation
72func (s *Spinner) Stop() {
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list